From nobody Fri Apr 26 15:19:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1559905003; cv=none; d=zoho.com; s=zohoarc; b=fzMyHuSROrCEhF7kGGVQ1dIyRxdMYW+kVGN3QMi1opi/iD/m7VPGSCA7cPAbb0l0/UtpxNwrOKYG8NvoJbMhMm/r2Plto88cfhLhiwPqhmg8SI5OYPfv++nTAOw986YQN9dKMXcvNL849OT+IqMlSvtApFmvWVv9tNvbPKG7g0U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559905003; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=v8MyNR+5eYgFChliOoJg4b+7MvC4qLYdPWNxg/WUJcs=; b=cWSfpUlBnAnkId9cBswzDvOQRrSjKhlLgKnEFf3kEyaeTUvaVvsCdlP6LUsJdZ8d2ZKw8kvySTFKzyjfGbxwo1A2ooXS15lhpEpF3WYOZd8R58EG0Dd4+QEBAfXkRz7ljYpcPAFdE2KjTcJYDBUHuZ8H2fAUURC6yUIN2Uq9VYU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1559905003678491.74246679315866; Fri, 7 Jun 2019 03:56:43 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hZCWb-00039w-W4; Fri, 07 Jun 2019 10:55:09 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hZCWb-00039r-1c for xen-devel@lists.xenproject.org; Fri, 07 Jun 2019 10:55:09 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com (unknown [40.107.1.101]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id b4c4648c-8912-11e9-a351-a7c6f19d0e43; Fri, 07 Jun 2019 10:55:05 +0000 (UTC) Received: from VI1PR0202MB2928.eurprd02.prod.outlook.com (10.171.106.11) by VI1PR0202MB2525.eurprd02.prod.outlook.com (10.173.78.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1965.12; Fri, 7 Jun 2019 10:55:02 +0000 Received: from VI1PR0202MB2928.eurprd02.prod.outlook.com ([fe80::fdcf:4771:37b7:9830]) by VI1PR0202MB2928.eurprd02.prod.outlook.com ([fe80::fdcf:4771:37b7:9830%9]) with mapi id 15.20.1965.011; Fri, 7 Jun 2019 10:55:02 +0000 X-Inumbo-ID: b4c4648c-8912-11e9-a351-a7c6f19d0e43 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bitdefender.onmicrosoft.com; s=selector1-bitdefender-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yOmDZVbbd1VkcYWVxPCrygTt0IMNXK0G5G9i4eDp2Uo=; b=i8axOcsFThHJ+j9/xXOzl5GMuEd3q5XZr9IaAzgh20xR8b6mug2jisRbqZhHdR8IemcEGHMWhBj2DBI9ejHBjA2hJL7v5yd92v8kl79RV4qV8qVlyI+45iyPRTbtD+k+5c4n2oI827VmctDKVWnwLli6aq9YMcocy6mU+vqVsOw= From: Alexandru Stefan ISAILA To: "xen-devel@lists.xenproject.org" Thread-Topic: [PATCH v3] x86/altp2m: Add a new hypercall to get the active altp2m index Thread-Index: AQHVHR91gFCC2wnfik6rp2c4QxPTkg== Date: Fri, 7 Jun 2019 10:55:02 +0000 Message-ID: <20190607105449.28167-1-aisaila@bitdefender.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6P193CA0113.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::18) To VI1PR0202MB2928.eurprd02.prod.outlook.com (2603:10a6:800:e3::11) authentication-results: spf=none (sender IP is ) smtp.mailfrom=aisaila@bitdefender.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [91.199.104.6] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ac0992f7-c90e-477a-534d-08d6eb369779 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:VI1PR0202MB2525; x-ms-traffictypediagnostic: VI1PR0202MB2525:|VI1PR0202MB2525: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:949; x-forefront-prvs: 0061C35778 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(346002)(39860400002)(396003)(376002)(136003)(189003)(199004)(86362001)(6512007)(71200400001)(478600001)(53936002)(5660300002)(5640700003)(6486002)(66066001)(6436002)(64756008)(73956011)(2501003)(71190400001)(6916009)(7416002)(25786009)(54906003)(3846002)(6116002)(81166006)(316002)(81156014)(8936002)(8676002)(305945005)(14454004)(7736002)(107886003)(2906002)(476003)(2616005)(50226002)(14444005)(256004)(66946007)(66476007)(386003)(6506007)(36756003)(2351001)(66446008)(68736007)(186003)(66556008)(102836004)(26005)(99286004)(4326008)(486006)(1076003)(52116002)(15583001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0202MB2525; H:VI1PR0202MB2928.eurprd02.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; received-spf: None (protection.outlook.com: bitdefender.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 7cme8tavcT/j9XuBTZ/YlerLHuYdy/KUPnkKK6M+IAp5BpOkn65xnXwMaqYA3mQcNcwI1i/egHd/5MmcXZtjhHTmtQ2DKfGicWaMRMtkR95QJMxjwI3/o+iPWOXRg5wpzRfI7uKRnDYB7G3pFDsxgx3KGCVqz7+auihAjNgV0LGQe4i4zp/IbKtShhhqQb6yDochQkwTvq/w/hCv7qr2S+wx0vUT/mw8x88szJ6KaMU5i4rOfVMGvlzXbl62iKLHd0tsgWMCW84BTZ8/pmnNcS8YfaXX/8kP9RMJb0WSsq4oywzHOunfB0MvxQIt6LkWV5yuIEMrBBEOe8CjMjARWOaDBl6H3/RLxXjQZEhnp1lSUWa/obnyZJzsrshAEA1bOh6PV1+b1+YuGV+Kuep/ojqBsKtCbdMjvO9COTiGqi4= MIME-Version: 1.0 X-OriginatorOrg: bitdefender.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac0992f7-c90e-477a-534d-08d6eb369779 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jun 2019 10:55:02.4718 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 487baf29-f1da-469a-9221-243f830c36f3 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: aisaila@bbu.bitdefender.biz X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0202MB2525 Subject: [Xen-devel] [PATCH v3] x86/altp2m: Add a new hypercall to get the active altp2m index X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: "sstabellini@kernel.org" , "wl@xen.org" , "konrad.wilk@oracle.com" , "George.Dunlap@eu.citrix.com" , "andrew.cooper3@citrix.com" , "ian.jackson@eu.citrix.com" , "tim@xen.org" , "julien.grall@arm.com" , "jbeulich@suse.com" , Alexandru Stefan ISAILA , "roger.pau@citrix.com" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The patch adds a new lib xc function (xc_altp2m_get_vcpu_p2m_idx) that uses a new hvmop (HVMOP_altp2m_get_p2m_idx) to get the active altp2m index from a given vcpu. Signed-off-by: Alexandru Isaila Reviewed-by: George Dunlap --- Changes since V2: - Update comment and title - Remove redundant max_vcpu check. --- tools/libxc/include/xenctrl.h | 2 ++ tools/libxc/xc_altp2m.c | 25 +++++++++++++++++++++++++ xen/arch/x86/hvm/hvm.c | 23 +++++++++++++++++++++++ xen/include/public/hvm/hvm_op.h | 8 ++++++++ 4 files changed, 58 insertions(+) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 538007a6dc..87526af4b4 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -1942,6 +1942,8 @@ int xc_altp2m_get_mem_access(xc_interface *handle, ui= nt32_t domid, int xc_altp2m_change_gfn(xc_interface *handle, uint32_t domid, uint16_t view_id, xen_pfn_t old_gfn, xen_pfn_t new_gfn); +int xc_altp2m_get_vcpu_p2m_idx(xc_interface *handle, uint32_t domid, + uint32_t vcpuid, uint16_t *p2midx); =20 /**=20 * Mem paging operations. diff --git a/tools/libxc/xc_altp2m.c b/tools/libxc/xc_altp2m.c index a86520c232..09dad0355e 100644 --- a/tools/libxc/xc_altp2m.c +++ b/tools/libxc/xc_altp2m.c @@ -352,3 +352,28 @@ int xc_altp2m_get_mem_access(xc_interface *handle, uin= t32_t domid, xc_hypercall_buffer_free(handle, arg); return rc; } + +int xc_altp2m_get_vcpu_p2m_idx(xc_interface *handle, uint32_t domid, + uint32_t vcpuid, uint16_t *altp2m_idx) +{ + int rc; + + DECLARE_HYPERCALL_BUFFER(xen_hvm_altp2m_op_t, arg); + + arg =3D xc_hypercall_buffer_alloc(handle, arg, sizeof(*arg)); + if ( arg =3D=3D NULL ) + return -1; + + arg->version =3D HVMOP_ALTP2M_INTERFACE_VERSION; + arg->cmd =3D HVMOP_altp2m_get_p2m_idx; + arg->domain =3D domid; + arg->u.get_vcpu_p2m_idx.vcpu_id =3D vcpuid; + + rc =3D xencall2(handle->xcall, __HYPERVISOR_hvm_op, HVMOP_altp2m, + HYPERCALL_BUFFER_AS_ARG(arg)); + if ( !rc ) + *altp2m_idx =3D arg->u.get_vcpu_p2m_idx.altp2m_idx; + + xc_hypercall_buffer_free(handle, arg); + return rc; +} diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 029eea3b85..4ee7e6ce47 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4500,6 +4500,7 @@ static int do_altp2m_op( case HVMOP_altp2m_set_mem_access_multi: case HVMOP_altp2m_get_mem_access: case HVMOP_altp2m_change_gfn: + case HVMOP_altp2m_get_p2m_idx: break; =20 default: @@ -4735,6 +4736,28 @@ static int do_altp2m_op( _gfn(a.u.change_gfn.old_gfn), _gfn(a.u.change_gfn.new_gfn)); break; + + case HVMOP_altp2m_get_p2m_idx: + { + struct vcpu *v; + + if ( !altp2m_active(d) ) + { + rc =3D -EOPNOTSUPP; + break; + } + + if ( (v =3D domain_vcpu(d, a.u.get_vcpu_p2m_idx.vcpu_id)) =3D=3D N= ULL ) + { + rc =3D -EINVAL; + break; + } + + a.u.get_vcpu_p2m_idx.altp2m_idx =3D altp2m_vcpu_idx(v); + rc =3D __copy_to_guest(arg, &a, 1) ? -EFAULT : 0; + break; + } + default: ASSERT_UNREACHABLE(); } diff --git a/xen/include/public/hvm/hvm_op.h b/xen/include/public/hvm/hvm_o= p.h index c6cd12f596..353f8034d9 100644 --- a/xen/include/public/hvm/hvm_op.h +++ b/xen/include/public/hvm/hvm_op.h @@ -304,6 +304,11 @@ struct xen_hvm_altp2m_change_gfn { typedef struct xen_hvm_altp2m_change_gfn xen_hvm_altp2m_change_gfn_t; DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_change_gfn_t); =20 +struct xen_hvm_altp2m_get_vcpu_p2m_idx { + uint32_t vcpu_id; + uint16_t altp2m_idx; +}; + struct xen_hvm_altp2m_op { uint32_t version; /* HVMOP_ALTP2M_INTERFACE_VERSION */ uint32_t cmd; @@ -332,6 +337,8 @@ struct xen_hvm_altp2m_op { #define HVMOP_altp2m_get_mem_access 12 /* Disable altp2m event notifications for a given VCPU */ #define HVMOP_altp2m_vcpu_disable_notify 13 +/* Get the active vcpu p2m index */ +#define HVMOP_altp2m_get_p2m_idx 14 domid_t domain; uint16_t pad1; uint32_t pad2; @@ -347,6 +354,7 @@ struct xen_hvm_altp2m_op { struct xen_hvm_altp2m_set_mem_access_multi set_mem_access_multi; struct xen_hvm_altp2m_suppress_ve suppress_ve; struct xen_hvm_altp2m_vcpu_disable_notify disable_notify; + struct xen_hvm_altp2m_get_vcpu_p2m_idx get_vcpu_p2m_idx; uint8_t pad[64]; } u; }; --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel