Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp245665rwb; Tue, 25 Jul 2023 15:16:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlG2oh0dbkQvuG3KkqYwcqhm+dmZnJYDGi33buTCFGdQjh5EatQ07pXUxHAGk5c9MCJGLEjC X-Received: by 2002:a17:906:cc0c:b0:970:1b2d:45cc with SMTP id ml12-20020a170906cc0c00b009701b2d45ccmr124043ejb.57.1690323393324; Tue, 25 Jul 2023 15:16:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690323393; cv=none; d=google.com; s=arc-20160816; b=yVGJmKM1CRDYzqB6laDSo9oA2jFHBbgxNzwf0AN853svqS29hQA1YvJAzfu66cTH6R cotk4pZoFOf5D4vGI8HYQxNPHs46FdFyUqnNAu/atg8nEWgBFYr/8SLHguBU7Bg91+Hl qMko8kWDckkY0Kn92QQdXJJxJV2RyxW4EGcnVoyFPUBzqHq4W56wQ7rudzjL2VTmyJwa vfCjMoPn/CrpXP+YqNlb1MrAfneI+LcsTOiLj8xEkpIAAIuzVDswAUa6fRk86RI/tYIK +mktYNjhdXZHRGaCrvuXIiOZKdQ9qgv1lyoEQ5XxrpSzGU8a55OjgNReVuqe0TCPFtyd j0+w== 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=QxayR1+38ThkDfjx5nIpGHvep+dFsgWVyrdLG8WNAS0=; fh=1/sgOwi5AuU8IZymeFKs1Rjnf4QELnrK+C7GntqU2hA=; b=uE9Yc9zWSCEolAf9CK3jWq5psKkcznZLFyhRbElpGfUE12X0Bc+Lhkmfg5qrcl3/F0 CHIfRJzMNdrtsH0tZC/+9b7XqPaF9Vdh0czE0mAybFqL2ppoxzefi7QGybp+rTITzXQM 1qpKx882Ta0Mj/AmfqnybSZjVVyhkqhui5qpYyfcRIJBuuKa0JQkNRcwP5Om/BS72+nr hJW4PBopwJ+eupGynrAmmDZZhjei6/Zbbb49cGqAG3ZFGJB7rOiD6lJQ9U1HyBWLS8QV Z/ZXgRHRibq40EdPGSQ6Z+PpvqraxmKH6EMuttb4L9BjoTcKhOyUFCqc7A0WvfNbwrT+ tbJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=iZXgv14x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k18-20020a17090627d200b00993a37af75csi7951940ejc.761.2023.07.25.15.16.08; Tue, 25 Jul 2023 15:16:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=iZXgv14x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231877AbjGYWEj (ORCPT + 99 others); Tue, 25 Jul 2023 18:04:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232068AbjGYWDJ (ORCPT ); Tue, 25 Jul 2023 18:03:09 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C82B3A89 for ; Tue, 25 Jul 2023 15:02:46 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id 41be03b00d2f7-55b2ab496ecso3122272a12.2 for ; Tue, 25 Jul 2023 15:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690322557; x=1690927357; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=QxayR1+38ThkDfjx5nIpGHvep+dFsgWVyrdLG8WNAS0=; b=iZXgv14xbs4ypE0+fJCZnqh6DPaH9qYrLol9WIcmwWp9hJrEMB06yc5oOt9YfjO/bh HwRybOKK0CbqEO25+XKNEteQEuanv0yjHGEUjLY9Jv8zD2Uc+5BvWqkDWJoQxKNQMvRn aqEfOTamPizEtwUdoyCGVEjqUSUYybSHYXzGVlNbam8Z9CGf0X3DxLb84YUre7PTpAcC Gs9C1FtJwVZ3eXrYO4wb83CPg2gEu/80AkOqMw2s9hLCli3wEAZt2UuvCT9wVOCiIeHf Lz/y69FzGU3OUSPJxChwBoTtdLRRvtEyvQx/DxGJZPrBEXoQjHHOp0inaCBkWv1QukPO /vEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690322557; x=1690927357; 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=QxayR1+38ThkDfjx5nIpGHvep+dFsgWVyrdLG8WNAS0=; b=JsVnEH/vMaVy9/gsjNFW74G/UNi6yh589z5TpPMDJCYsqe05FDWjwtL3fLiRB+rOku 1KroMiYcBQX76XeESDzX+f8shBwdRbbdBz2sw//8IQx6kJY1T4sVdX0XEW6O+Ncx9P2n C8wIaCcSkPfcVtZiMWFIv2DCaWgOwGD6HwAs3KfKq3zbEOpwc/pw5ov9sX0mZ/GS5qBt 2/343SIS+lvz6QJf+dIEv2pn6un0r74fDSY8N/6h+Dxnk4EWdaRLwkVU0hDn56TAOUB+ m40mtOIAvdAdgMltZPbUo+6dg9mvxL57P0HkSZdHJpux4JUQ06PuaDy8F0tRr09TafZM GB2A== X-Gm-Message-State: ABy/qLY3QsbIHDXUuNxDmvz7nQ+RKIYIddLJlKT6XAXxKyscrFuSL670 UT8Nj5FU0Hcpwn4TxS6pXY2YV+Js6Dg7 X-Received: from afranji.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:47f1]) (user=afranji job=sendgmr) by 2002:a63:6f86:0:b0:55a:12cf:3660 with SMTP id k128-20020a636f86000000b0055a12cf3660mr2082pgc.1.1690322556693; Tue, 25 Jul 2023 15:02:36 -0700 (PDT) Date: Tue, 25 Jul 2023 22:01:18 +0000 In-Reply-To: <20230725220132.2310657-1-afranji@google.com> Mime-Version: 1.0 References: <20230725220132.2310657-1-afranji@google.com> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog Message-ID: <20230725220132.2310657-26-afranji@google.com> Subject: [PATCH v4 25/28] KVM: selftests: TDX: Add support for TDG.MEM.PAGE.ACCEPT From: Ryan Afranji To: linux-kselftest@vger.kernel.org Cc: pbonzini@redhat.com, seanjc@google.com, isaku.yamahata@intel.com, sagis@google.com, erdemaktas@google.com, afranji@google.com, runanwang@google.com, shuah@kernel.org, drjones@redhat.com, maz@kernel.org, bgardon@google.com, jmattson@google.com, dmatlack@google.com, peterx@redhat.com, oupton@google.com, ricarkol@google.com, yang.zhong@intel.com, wei.w.wang@intel.com, xiaoyao.li@intel.com, pgonda@google.com, eesposit@redhat.com, borntraeger@de.ibm.com, eric.auger@redhat.com, wangyanan55@huawei.com, aaronlewis@google.com, vkuznets@redhat.com, pshier@google.com, axelrasmussen@google.com, zhenzhong.duan@intel.com, maciej.szmigiero@oracle.com, like.xu@linux.intel.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, ackerleytng@google.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ackerley Tng Signed-off-by: Ackerley Tng Change-Id: I93d3c84735df06b300a84c7c7bb66a3128354739 Signed-off-by: Ryan Afranji --- 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); +} -- 2.41.0.487.g6d72f3e995-goog