From patchwork Tue Dec 12 20:46:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Shahar X-Patchwork-Id: 177578 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7994208vqy; Tue, 12 Dec 2023 12:49:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFx9HNqIdLVinTmqMda6oRFzzF6jqeZ+odaDZhYKSAqIpEgwZo47GSgydjQe1fCLzOg+Bz6 X-Received: by 2002:a17:90b:954:b0:286:6cc1:8667 with SMTP id dw20-20020a17090b095400b002866cc18667mr3270335pjb.76.1702414192674; Tue, 12 Dec 2023 12:49:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702414192; cv=none; d=google.com; s=arc-20160816; b=ScARxoClxkDoCS/9kLQwUxSY10d0SfzL1pW8wcVFEg3qsku8Y1/ItZYOsXHtyVv5gb sH+QsDSVD43uCQjC1fQ7p1ZHhaeBcrwPqQDtGqS4hpQatYslG/NKbCmxJ56zFEf/kSkB /b5Kcprza9RQjsCC8ahPFZX2XfpfqJnTF5c8vrHLZ2h2Y1le0p+ziKUSaEDvfr5YWqBG rJZx2yTZFa5XGu3Mi5aQjfh1Px2Dmd1YMviUa2hu+poGDBoJWFjd0Uen2z/GaKud6jud qd6pLRKuMgpAitESxlFIS2DA4l5aKw0C68PiWBDfOnvIbph75kt9eBHBuy4HClTdaG3D Yl8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=spishPpmYPggI3jrHmifejwbO19KNsurBr8OcADllgg=; fh=Y5ua58y+ybdOPwRkMynUdu+Hv1LrozBumh8skcuOhBI=; b=uAmQ7zyH123aE5yeK9iYEEE9VylnA5FfXw/oErvVkAk/IGR35z9QMbnU+2fUT6FzXm OUU1HNn8rPzObsUKvlVsK/LLDHmwZOFsAOZRvqFAcf6BOJkzEOF8gI8VKHnqFCe9Qh0s pyYAUGjK4qtJO4MWtOhSIA1EIWW1BBlbmTuzrDRB5Nc11NZw5tsgsiSN0hHdZ3UK4fsE hzuvBCoxdiwlTehhiP+t+lQDq2iuVuwmDGEN0e4QRSFGl3gJRxyzBe9nKsLRcgdBn0wM l+eboFuvrcjsbuiBTI1M5LzaAYS+qGjgUwPpkf2agZJCXJ92hDTjdd+dehqAxLVwaTVH 5Mfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=AEo3KYgZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id b14-20020a17090a7ace00b002861c962e15si8375696pjl.15.2023.12.12.12.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 12:49:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=AEo3KYgZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 3812D8107556; Tue, 12 Dec 2023 12:49:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377398AbjLLUt1 (ORCPT + 99 others); Tue, 12 Dec 2023 15:49:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377391AbjLLUsw (ORCPT ); Tue, 12 Dec 2023 15:48:52 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1C271BEF for ; Tue, 12 Dec 2023 12:47:44 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1d08383e566so54491525ad.2 for ; Tue, 12 Dec 2023 12:47:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702414063; x=1703018863; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=spishPpmYPggI3jrHmifejwbO19KNsurBr8OcADllgg=; b=AEo3KYgZ5i4SDTChjzjNMVNy33d2JI1HsAM93C7g2gSTWDWPhwfbWiB8PxD5l9Kw0W aUryWzAf7iYF+PLR5rzIWHfzcC/XYF6woNz6CJTUWVcpwa7HSwujY5Zxr50q/Xm82vUb Ub60azWqR4PIeT08pUtRasltsapmhsVQnMkZb1BpktQodsAbtDlCS/CkW4QlkeMKzuij UClgkq1wZfp0hsgR2MiNVBofEGKLAIyNV7u7xSku5HIzACXkNTIII2DVTaUmZEh0zOuh 7J+491qVYITd/vnf23XhOAz1S9bNyczCyinHmdrSsL4dbS2/NB++8/9nzM02lrWk71xR OOeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702414063; x=1703018863; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=spishPpmYPggI3jrHmifejwbO19KNsurBr8OcADllgg=; b=jq3IRQmBlBlRMG083VzOkqq3fpqkLUmdL/EdJEFSZEdGqGGECfGYoLFg2rzgcrQDy/ HH1+CCr3kSZ9i5ozg5QjSjYTGEHXgGMPKtIj1Egn6sioEdFSW99evn3b+pRBDdZW/VCM ensPE1meO0UmTMvM0p+RnAivI15t1RYB2pVNjP/H+E/G604o22KCUJvIfBjjvWDwBvSe BFlKMyiKyRkfN80gMYqkWZGlbp7Az8bS1GXOyKb500LmQkCkPhaOZETFQVvaAEIGJSUK X9jBqFD4stlsl6T0WxerJBj3wnXFCg+01LLYF01jq3une9aq8Org52jTraGXxuzGOsA3 RPbA== X-Gm-Message-State: AOJu0YxM+CNi2SvXrElAHKOtCx5jtvSC+G3CHaFf6JsiZaRKAFRTjWHc HN0b+SW4DYRAEW3wpdbh08fP5Yy27g== X-Received: from sagi.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:241b]) (user=sagis job=sendgmr) by 2002:a17:903:234a:b0:1d0:6638:b9da with SMTP id c10-20020a170903234a00b001d06638b9damr52616plh.8.1702414063541; Tue, 12 Dec 2023 12:47:43 -0800 (PST) Date: Tue, 12 Dec 2023 12:46:40 -0800 In-Reply-To: <20231212204647.2170650-1-sagis@google.com> Mime-Version: 1.0 References: <20231212204647.2170650-1-sagis@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231212204647.2170650-26-sagis@google.com> Subject: [RFC PATCH v5 25/29] KVM: selftests: TDX: Add support for TDG.MEM.PAGE.ACCEPT From: Sagi Shahar To: linux-kselftest@vger.kernel.org, Ackerley Tng , Ryan Afranji , Erdem Aktas , Sagi Shahar , Isaku Yamahata Cc: Sean Christopherson , Paolo Bonzini , Shuah Khan , Peter Gonda , Haibo Xu , Chao Peng , Vishal Annapurve , Roger Wang , Vipin Sharma , jmattson@google.com, dmatlack@google.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 12 Dec 2023 12:49:50 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785110664742469155 X-GMAIL-MSGID: 1785110664742469155 From: Ackerley Tng Signed-off-by: Ackerley Tng Signed-off-by: Ryan Afranji Signed-off-by: Sagi Shahar --- tools/testing/selftests/kvm/include/x86_64/tdx/tdx.h | 2 ++ tools/testing/selftests/kvm/lib/x86_64/tdx/tdx.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/tools/testing/selftests/kvm/include/x86_64/tdx/tdx.h b/tools/testing/selftests/kvm/include/x86_64/tdx/tdx.h index db4cc62abb5d..b71bcea40b5c 100644 --- a/tools/testing/selftests/kvm/include/x86_64/tdx/tdx.h +++ b/tools/testing/selftests/kvm/include/x86_64/tdx/tdx.h @@ -6,6 +6,7 @@ #include "kvm_util_base.h" #define TDG_VP_INFO 1 +#define TDG_MEM_PAGE_ACCEPT 6 #define TDG_VP_VMCALL_GET_TD_VM_CALL_INFO 0x10000 #define TDG_VP_VMCALL_MAP_GPA 0x10001 @@ -38,5 +39,6 @@ uint64_t tdg_vp_info(uint64_t *rcx, uint64_t *rdx, uint64_t *r8, uint64_t *r9, uint64_t *r10, uint64_t *r11); uint64_t tdg_vp_vmcall_map_gpa(uint64_t address, uint64_t size, uint64_t *data_out); +uint64_t tdg_mem_page_accept(uint64_t gpa, uint8_t level); #endif // SELFTEST_TDX_TDX_H diff --git a/tools/testing/selftests/kvm/lib/x86_64/tdx/tdx.c b/tools/testing/selftests/kvm/lib/x86_64/tdx/tdx.c index 061a5c0bef34..d8c4ab635c06 100644 --- a/tools/testing/selftests/kvm/lib/x86_64/tdx/tdx.c +++ b/tools/testing/selftests/kvm/lib/x86_64/tdx/tdx.c @@ -236,3 +236,8 @@ uint64_t tdg_vp_vmcall_map_gpa(uint64_t address, uint64_t size, uint64_t *data_o *data_out = args.r11; return ret; } + +uint64_t tdg_mem_page_accept(uint64_t gpa, uint8_t level) +{ + return __tdx_module_call(TDG_MEM_PAGE_ACCEPT, gpa | level, 0, 0, 0, NULL); +}