From patchwork Tue Dec 17 15:12:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexandru Stefan ISAILA X-Patchwork-Id: 11297887 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E616112B for ; Tue, 17 Dec 2019 15:13:33 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4D0F52146E for ; Tue, 17 Dec 2019 15:13:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bitdefender.onmicrosoft.com header.i=@bitdefender.onmicrosoft.com header.b="CApFzyrk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D0F52146E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bitdefender.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ihEWZ-0008AX-0q; Tue, 17 Dec 2019 15:12:35 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ihEWX-0008AO-Bv for xen-devel@lists.xenproject.org; Tue, 17 Dec 2019 15:12:33 +0000 X-Inumbo-ID: a09117b6-20df-11ea-b6f1-bc764e2007e4 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (unknown [40.107.5.102]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a09117b6-20df-11ea-b6f1-bc764e2007e4; Tue, 17 Dec 2019 15:12:23 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R62Ng1T0L5ZBK1oUbMvt2wJqtdmoKkcVI0Uo45hQS5Rqg4EpxMPSrkBGT48tfKzNEvMB4u4okOEoWpUB1R0ydUuuEqyYEjk4pmWEIXepTZRLIqYKD+O5r3VIwwaWAJK4qArX+WC4Uxywpf7j9LHJkTePd/iGhjUhoHNGBWkFMSVCKBCgIwqQygLc7Vg0/8rwSYTw5lzRxN0pV7wTrbhmgPpQoaGLw7wOoJp4xABKWmTfgzgx0WJIXgLwHK0ELvviBhPMR6seskVs/uYPjxZF06W3LEsxqSyBULNMuqYxpG9WvGJ3gaW3D/cV9atpueOmvYkway5iihzRpJI7OWE9vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dNdnDTkXFSB7LLx6bNq04Oc0bd8/QYnLUPngVXmiRD0=; b=Kn1QZ2zPaLCZyTITnbHiUh9gEnqLvEPffhV4rkEIQVbTKCOMJvc61mxMtbgZqPAczdqsksdm2tPFV/dIxRZ5yUL9hWeriROdCEqVG1iiEETx/yTH8+koFQr0lwtMpWaaAZ7hu77FTSpSAkRolVyRPkLQb8DD5lTHgwqHmYAICnXAz/NQ8JfLI5WgHDxB3lr2AOnrN5qQc8A0mTvUcQ5ZizpCnITz1Wf6LanyTOZO/KulAaKyjQa26B8smLQHZiXYOIABmE3U/SUemBVlx3Fb4IVoIL+qwcJRdRg+C7ignsbyvFS6zORKcdjTtpktH+vpRsBU2+NozAsDDXOQiCI58A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bitdefender.com; dmarc=pass action=none header.from=bitdefender.com; dkim=pass header.d=bitdefender.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bitdefender.onmicrosoft.com; s=selector2-bitdefender-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dNdnDTkXFSB7LLx6bNq04Oc0bd8/QYnLUPngVXmiRD0=; b=CApFzyrk0mlMDcSadvV/d7ZUlanzXmS+m7aVES+7/PlT/2HEmwtYEBdN6pUdWDbsMBYgnAMaNTdghBKp3Ljfj+sRsO2IjLpx2+Nk1zooYnlxP3QQLDlJ+cjiXhDsw5VdDPZKhF+Fgtm5nygmi5D0onhECyNDNDc+49NlW67VOq8= Received: from AM0PR02MB5553.eurprd02.prod.outlook.com (10.255.30.78) by AM0PR02MB4386.eurprd02.prod.outlook.com (20.178.17.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2538.20; Tue, 17 Dec 2019 15:12:22 +0000 Received: from AM0PR02MB5553.eurprd02.prod.outlook.com ([fe80::8cec:7638:734c:89d]) by AM0PR02MB5553.eurprd02.prod.outlook.com ([fe80::8cec:7638:734c:89d%4]) with mapi id 15.20.2538.019; Tue, 17 Dec 2019 15:12:22 +0000 From: Alexandru Stefan ISAILA To: "xen-devel@lists.xenproject.org" Thread-Topic: [PATCH V4 1/4] x86/mm: Add array_index_nospec to guest provided index values Thread-Index: AQHVtOxhsG39wuvEP0STO9uvU+j0gQ== Date: Tue, 17 Dec 2019 15:12:21 +0000 Message-ID: <20191217151144.9781-1-aisaila@bitdefender.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM0PR01CA0067.eurprd01.prod.exchangelabs.com (2603:10a6:208:e6::44) To AM0PR02MB5553.eurprd02.prod.outlook.com (2603:10a6:208:160::14) 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: d067ba9e-8c9c-4f83-ca0c-08d7830383e9 x-ms-traffictypediagnostic: AM0PR02MB4386:|AM0PR02MB4386:|AM0PR02MB4386: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:923; x-forefront-prvs: 02543CD7CD x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(136003)(396003)(39860400002)(346002)(376002)(189003)(199004)(6512007)(52116002)(64756008)(86362001)(186003)(8936002)(6486002)(4326008)(2906002)(54906003)(66476007)(71200400001)(66556008)(66946007)(36756003)(26005)(81156014)(81166006)(5660300002)(8676002)(6506007)(478600001)(66446008)(1076003)(2616005)(316002)(6916009); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR02MB4386; H:AM0PR02MB5553.eurprd02.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: bitdefender.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: O/DKVO6WLk5mFLsOwWvTpR9EV9dOb/z8utBIF47hT/GmWxtlgygxrYXbFHURww2fBdoahCSbAU36jUcW9Af2P+DzsJFgABqDJstVvyxzROv/Cyma3xwE+P/8avTSh4/Kk5EhIFXsSq4PbkTGvBbhjvPoYngpML5prLyyw5D3ZbGcxbgFQoiahCzLrYlm8iebb0EYUtsAE5hAqXfoWTuPq8XbXdZJ6oF6w+AgGCJPXkTbeBzfbXbOujX1AMOUpqw4YTdrQjY4+uqitzCr1E5Fuu/jtC9sygJijnuBH5xtozAPxojbyfQQPl6adAqz2CdCj/FaR6pQEARfnpdMPHYaOQp/Q4sRit1eQYX12g8+YnLijmYlyWGdDF8nBQ0Ppt3rZYjRUTJl6rMyAzsh2ipeJc6/9+EuQQcn5ZDmHtkRXJu2oUJq/FCwdx27zs1pgrEl Content-ID: <1944D3022A1EC5408CCD757F6F1CA470@eurprd02.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: bitdefender.com X-MS-Exchange-CrossTenant-Network-Message-Id: d067ba9e-8c9c-4f83-ca0c-08d7830383e9 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Dec 2019 15:12:22.0510 (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: A4teMOnRYkBZigPSnz6BzBUsDtClQtl/013J/4L4xfNdJRcIMDnzaZnH0IuLq5LRt496/1IKqGcweibRK2gV5UF8Z71xJP43w54Eyy5pPPg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR02MB4386 Subject: [Xen-devel] [PATCH V4 1/4] x86/mm: Add array_index_nospec to guest provided index values 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: Petre Ovidiu PIRCALABU , Kevin Tian , Tamas K Lengyel , Wei Liu , Razvan COJOCARU , George Dunlap , Andrew Cooper , Jan Beulich , Jun Nakajima , Alexandru Stefan ISAILA , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This patch aims to sanitize indexes, potentially guest provided values, for altp2m_eptp[] and altp2m_p2m[] arrays. Signed-off-by: Alexandru Isaila Acked-by: Tamas K Lengyel --- CC: Razvan Cojocaru CC: Tamas K Lengyel CC: Petre Pircalabu CC: George Dunlap CC: Jan Beulich CC: Andrew Cooper CC: Wei Liu CC: "Roger Pau Monné" CC: Jun Nakajima CC: Kevin Tian --- xen/arch/x86/mm/mem_access.c | 15 +++++++++------ xen/arch/x86/mm/p2m-ept.c | 5 +++-- xen/arch/x86/mm/p2m.c | 27 +++++++++++++++++---------- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c index 320b9fe621..70f3528bb1 100644 --- a/xen/arch/x86/mm/mem_access.c +++ b/xen/arch/x86/mm/mem_access.c @@ -367,10 +367,11 @@ long p2m_set_mem_access(struct domain *d, gfn_t gfn, uint32_t nr, if ( altp2m_idx ) { if ( altp2m_idx >= MAX_ALTP2M || - d->arch.altp2m_eptp[altp2m_idx] == mfn_x(INVALID_MFN) ) + d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] == + mfn_x(INVALID_MFN) ) return -EINVAL; - ap2m = d->arch.altp2m_p2m[altp2m_idx]; + ap2m = d->arch.altp2m_p2m[array_index_nospec(altp2m_idx, MAX_ALTP2M)]; } #else ASSERT(!altp2m_idx); @@ -426,10 +427,11 @@ long p2m_set_mem_access_multi(struct domain *d, if ( altp2m_idx ) { if ( altp2m_idx >= MAX_ALTP2M || - d->arch.altp2m_eptp[altp2m_idx] == mfn_x(INVALID_MFN) ) + d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] == + mfn_x(INVALID_MFN) ) return -EINVAL; - ap2m = d->arch.altp2m_p2m[altp2m_idx]; + ap2m = d->arch.altp2m_p2m[array_index_nospec(altp2m_idx, MAX_ALTP2M)]; } #else ASSERT(!altp2m_idx); @@ -492,10 +494,11 @@ int p2m_get_mem_access(struct domain *d, gfn_t gfn, xenmem_access_t *access, else if ( altp2m_idx ) /* altp2m view 0 is treated as the hostp2m */ { if ( altp2m_idx >= MAX_ALTP2M || - d->arch.altp2m_eptp[altp2m_idx] == mfn_x(INVALID_MFN) ) + d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] == + mfn_x(INVALID_MFN) ) return -EINVAL; - p2m = d->arch.altp2m_p2m[altp2m_idx]; + p2m = d->arch.altp2m_p2m[array_index_nospec(altp2m_idx, MAX_ALTP2M)]; } #else ASSERT(!altp2m_idx); diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index b5517769c9..e088a63f56 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -1353,7 +1353,8 @@ void setup_ept_dump(void) void p2m_init_altp2m_ept(struct domain *d, unsigned int i) { - struct p2m_domain *p2m = d->arch.altp2m_p2m[i]; + struct p2m_domain *p2m = + d->arch.altp2m_p2m[array_index_nospec(i, MAX_ALTP2M)]; struct p2m_domain *hostp2m = p2m_get_hostp2m(d); struct ept_data *ept; @@ -1366,7 +1367,7 @@ void p2m_init_altp2m_ept(struct domain *d, unsigned int i) p2m->max_mapped_pfn = p2m->max_remapped_gfn = 0; ept = &p2m->ept; ept->mfn = pagetable_get_pfn(p2m_get_pagetable(p2m)); - d->arch.altp2m_eptp[i] = ept->eptp; + d->arch.altp2m_eptp[array_index_nospec(i, MAX_EPTP)] = ept->eptp; } unsigned int p2m_find_altp2m_by_eptp(struct domain *d, uint64_t eptp) diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index ba126f790a..7e7f4f1a7c 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -2499,7 +2499,7 @@ static void p2m_reset_altp2m(struct domain *d, unsigned int idx, struct p2m_domain *p2m; ASSERT(idx < MAX_ALTP2M); - p2m = d->arch.altp2m_p2m[idx]; + p2m = d->arch.altp2m_p2m[array_index_nospec(idx, MAX_ALTP2M)]; p2m_lock(p2m); @@ -2540,7 +2540,7 @@ static int p2m_activate_altp2m(struct domain *d, unsigned int idx) ASSERT(idx < MAX_ALTP2M); - p2m = d->arch.altp2m_p2m[idx]; + p2m = d->arch.altp2m_p2m[array_index_nospec(idx, MAX_ALTP2M)]; hostp2m = p2m_get_hostp2m(d); p2m_lock(p2m); @@ -2622,9 +2622,10 @@ int p2m_destroy_altp2m_by_id(struct domain *d, unsigned int idx) rc = -EBUSY; altp2m_list_lock(d); - if ( d->arch.altp2m_eptp[idx] != mfn_x(INVALID_MFN) ) + if ( d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] != + mfn_x(INVALID_MFN) ) { - p2m = d->arch.altp2m_p2m[idx]; + p2m = d->arch.altp2m_p2m[array_index_nospec(idx, MAX_ALTP2M)]; if ( !_atomic_read(p2m->active_vcpus) ) { @@ -2686,11 +2687,13 @@ int p2m_change_altp2m_gfn(struct domain *d, unsigned int idx, mfn_t mfn; int rc = -EINVAL; - if ( idx >= MAX_ALTP2M || d->arch.altp2m_eptp[idx] == mfn_x(INVALID_MFN) ) + if ( idx >= MAX_ALTP2M || + d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] == + mfn_x(INVALID_MFN) ) return rc; hp2m = p2m_get_hostp2m(d); - ap2m = d->arch.altp2m_p2m[idx]; + ap2m = d->arch.altp2m_p2m[array_index_nospec(idx, MAX_ALTP2M)]; p2m_lock(hp2m); p2m_lock(ap2m); @@ -3030,10 +3033,12 @@ int p2m_set_suppress_ve(struct domain *d, gfn_t gfn, bool suppress_ve, if ( altp2m_idx > 0 ) { if ( altp2m_idx >= MAX_ALTP2M || - d->arch.altp2m_eptp[altp2m_idx] == mfn_x(INVALID_MFN) ) + d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] == + mfn_x(INVALID_MFN) ) return -EINVAL; - p2m = ap2m = d->arch.altp2m_p2m[altp2m_idx]; + p2m = ap2m = d->arch.altp2m_p2m[array_index_nospec(altp2m_idx, + MAX_ALTP2M)]; } else p2m = host_p2m; @@ -3073,10 +3078,12 @@ int p2m_get_suppress_ve(struct domain *d, gfn_t gfn, bool *suppress_ve, if ( altp2m_idx > 0 ) { if ( altp2m_idx >= MAX_ALTP2M || - d->arch.altp2m_eptp[altp2m_idx] == mfn_x(INVALID_MFN) ) + d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] == + mfn_x(INVALID_MFN) ) return -EINVAL; - p2m = ap2m = d->arch.altp2m_p2m[altp2m_idx]; + p2m = ap2m = d->arch.altp2m_p2m[array_index_nospec(altp2m_idx, + MAX_ALTP2M)]; } else p2m = host_p2m; From patchwork Tue Dec 17 15:12:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexandru Stefan ISAILA X-Patchwork-Id: 11297889 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BD52C14B7 for ; Tue, 17 Dec 2019 15:13:49 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8D5882146E for ; Tue, 17 Dec 2019 15:13:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bitdefender.onmicrosoft.com header.i=@bitdefender.onmicrosoft.com header.b="Ufr1rbV+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D5882146E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bitdefender.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ihEWi-0008CN-Ew; Tue, 17 Dec 2019 15:12:44 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ihEWg-0008Bv-JB for xen-devel@lists.xenproject.org; Tue, 17 Dec 2019 15:12:42 +0000 X-Inumbo-ID: a69eafd8-20df-11ea-b6f1-bc764e2007e4 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (unknown [40.107.5.102]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a69eafd8-20df-11ea-b6f1-bc764e2007e4; Tue, 17 Dec 2019 15:12:33 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=npc6E7hfAb/6d4ckjxiKauCZtCyMWNNv+ADaAvs4bOyN5OSSA9JGcPZLc6pwb4tFRNiX9sYLnPK/6GoU+mokU8EF6sIQbd3tZNmaY7WSYlXO+Oh/Y+YHq2x1NutsE6oxturlVsxUMKZImTEmJdgrT86flhMkmDc84WPNfnX4ZcWxgfzI0fBlr5N1FxmgAe3u26XUlw4LcrHAZHmJkAo2Jlj5i47HlDgRUGEvHXDJhKLzzWOqzEr4i56cCbNl6c74PivWvouXlfEsdk3QGlpvILkLOUEQi4FA8pZximYFVPdHhs5Yo5Hr+mumZSuAM1ugmcgALcYyz4Uw/bEIhkCDPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5Ye3jrTk8Fzpo5sg2oh2es9+FqCrKKcjqncyVkCrfYE=; b=oPGnIe72ay85MMjdsb35kk5kkfLxYd7/n8JfZsJ1vkIOwUFJSQD2YTa0f85+ALzB5e7i9C2S4MszoJ5FiYYoR0ZwVGJ8MicSCrUV7NYJENeaCxO8NdaTgCZ1Q9O8Ige6osZGaPcqPxnMRDB9c22JgOPA9haMuNbSllbHPYHYYOUIYMkhySX8AlP87uhI1NeBWk05BfOs7ZB6B4ME43cI4yKk1RxKug0/AcUMBAqI+Xe2gacOzRC/2FgihT7633t9rpkei1M4uBDHrDzEegM/mjJ/rucSxWAVniruVfnFOhdJbqUVAWaJzWX88i9/Sto8jwD3ci4erU0NGS8zx2efeQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bitdefender.com; dmarc=pass action=none header.from=bitdefender.com; dkim=pass header.d=bitdefender.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bitdefender.onmicrosoft.com; s=selector2-bitdefender-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5Ye3jrTk8Fzpo5sg2oh2es9+FqCrKKcjqncyVkCrfYE=; b=Ufr1rbV+mbxHqU800UfZnFQ1/QODneD+BvcHvmstdNET2QjoVLSF+JhonwWuukBy65pBszu09uzFCY9LREywVBg3in5wY1laV9pA7s4HpK/+jpCVqkSdr3GOL/ZNanP7WHGK5gQfh8XG3zk2XVfD9rLHImfzqitq1vKQzOFJx40= Received: from AM0PR02MB5553.eurprd02.prod.outlook.com (10.255.30.78) by AM0PR02MB4386.eurprd02.prod.outlook.com (20.178.17.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2538.20; Tue, 17 Dec 2019 15:12:31 +0000 Received: from AM0PR02MB5553.eurprd02.prod.outlook.com ([fe80::8cec:7638:734c:89d]) by AM0PR02MB5553.eurprd02.prod.outlook.com ([fe80::8cec:7638:734c:89d%4]) with mapi id 15.20.2538.019; Tue, 17 Dec 2019 15:12:31 +0000 From: Alexandru Stefan ISAILA To: "xen-devel@lists.xenproject.org" Thread-Topic: [PATCH V4 2/4] x86/altp2m: Add hypercall to set a range of sve bits Thread-Index: AQHVtOxnMZNvtoiQIE62yqEH5VgLvA== Date: Tue, 17 Dec 2019 15:12:31 +0000 Message-ID: <20191217151144.9781-2-aisaila@bitdefender.com> References: <20191217151144.9781-1-aisaila@bitdefender.com> In-Reply-To: <20191217151144.9781-1-aisaila@bitdefender.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM0PR01CA0067.eurprd01.prod.exchangelabs.com (2603:10a6:208:e6::44) To AM0PR02MB5553.eurprd02.prod.outlook.com (2603:10a6:208:160::14) 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: e424ed4a-de6c-4ee7-485b-08d7830389b2 x-ms-traffictypediagnostic: AM0PR02MB4386:|AM0PR02MB4386:|AM0PR02MB4386: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:83; x-forefront-prvs: 02543CD7CD x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(136003)(396003)(39860400002)(346002)(376002)(189003)(199004)(7416002)(6512007)(52116002)(64756008)(86362001)(186003)(8936002)(6486002)(4326008)(2906002)(54906003)(107886003)(66476007)(71200400001)(66556008)(66946007)(36756003)(26005)(81156014)(81166006)(5660300002)(8676002)(6506007)(478600001)(66446008)(1076003)(2616005)(316002)(6916009); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR02MB4386; H:AM0PR02MB5553.eurprd02.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: bitdefender.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: EnEhYEFyc8I/6RKCBwYxsBw+g/HO2QKmmNcAj2HBYDK3qI3kvTQ90Tv82bM0wZmMGRfQIZLmu/9j5EyfSX6d3Z899Un1OvT9+oRfT54HXFdKGIJMTr1vVQDTfymOFkE9iYCKJeEyzeGwISLx1HYcT5fJ4aUEF1fPR2JxowwGMA7ldfxZuSvaig5OrNT1mX/9VH3a6EY2vtzmACqIWWM1/xLOUrnkxR5QrTwR6CI3RdQ6SYLayVxzEn03Wx33lK7dL5YHoJn1RlSwiCaGdMvu0F90PB3hFznXA0N+IYTR14/UixelN8h670dwHrC6lRy/8fCfjveAYPyH0Xay1KOcsFdywUlAb1PrN8eJ6RIFCxX81wg33z28xcL49R6iS/gtricRC3ia0ByyugqxeWoyMVFA++XyGPSST7S8RYnJIL4+Jo1f8gCz6KGfiU3gMAvY Content-ID: MIME-Version: 1.0 X-OriginatorOrg: bitdefender.com X-MS-Exchange-CrossTenant-Network-Message-Id: e424ed4a-de6c-4ee7-485b-08d7830389b2 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Dec 2019 15:12:31.6266 (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: WVqs/bu4Sceq/q/29XVEceoO1vbqpcJVfvXroP9HqNFNSqabScfs201Q3vJbdafY7pnE/eUMRZsiwoUpiCmwpmknkEH4+AgfExhYhCvmkXw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR02MB4386 Subject: [Xen-devel] [PATCH V4 2/4] x86/altp2m: Add hypercall to set a range of sve bits 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: Petre Ovidiu PIRCALABU , Stefano Stabellini , Julien Grall , Razvan COJOCARU , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tamas K Lengyel , Jan Beulich , Alexandru Stefan ISAILA , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" By default the sve bits are not set. This patch adds a new hypercall, xc_altp2m_set_supress_ve_multi(), to set a range of sve bits. The core function, p2m_set_suppress_ve_multi(), does not brake in case of a error and it is doing a best effort for setting the bits in the given range. A check for continuation is made in order to have preemption on big ranges. The gfn of the first error is stored in xen_hvm_altp2m_suppress_ve_multi.first_error and the error code is stored in xen_hvm_altp2m_suppress_ve_multi.first_error_code. If no error occurred the values will be 0. Signed-off-by: Alexandru Isaila --- CC: Ian Jackson CC: Wei Liu CC: Andrew Cooper CC: George Dunlap CC: Jan Beulich CC: Julien Grall CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: "Roger Pau Monné" CC: George Dunlap CC: Razvan Cojocaru CC: Tamas K Lengyel CC: Petre Pircalabu --- Changes since V3: - Update commit message - Check rc and __copy_to_guest() in the same if - Fix style issue - Fix comment typo - Init p2m with host_p2m - Use array_index_nospec() in altp2m_p2m[] and altp2m_eptp[] - Drop opaque - Use pad2 to return first error code - Update first_gfn - Stop the range loop at cpuid->extd.maxphysaddr. --- tools/libxc/include/xenctrl.h | 4 +++ tools/libxc/xc_altp2m.c | 33 +++++++++++++++++ xen/arch/x86/hvm/hvm.c | 15 ++++++++ xen/arch/x86/mm/p2m.c | 64 +++++++++++++++++++++++++++++++++ xen/include/public/hvm/hvm_op.h | 13 +++++++ xen/include/xen/mem_access.h | 3 ++ 6 files changed, 132 insertions(+) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index f4431687b3..2ace8ea80e 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -1923,6 +1923,10 @@ int xc_altp2m_switch_to_view(xc_interface *handle, uint32_t domid, uint16_t view_id); int xc_altp2m_set_suppress_ve(xc_interface *handle, uint32_t domid, uint16_t view_id, xen_pfn_t gfn, bool sve); +int xc_altp2m_set_supress_ve_multi(xc_interface *handle, uint32_t domid, + uint16_t view_id, xen_pfn_t first_gfn, + xen_pfn_t last_gfn, bool sve, + xen_pfn_t *error_gfn, uint32_t *error_code); int xc_altp2m_get_suppress_ve(xc_interface *handle, uint32_t domid, uint16_t view_id, xen_pfn_t gfn, bool *sve); int xc_altp2m_set_mem_access(xc_interface *handle, uint32_t domid, diff --git a/tools/libxc/xc_altp2m.c b/tools/libxc/xc_altp2m.c index 09dad0355e..9f7e8315b3 100644 --- a/tools/libxc/xc_altp2m.c +++ b/tools/libxc/xc_altp2m.c @@ -234,6 +234,39 @@ int xc_altp2m_set_suppress_ve(xc_interface *handle, uint32_t domid, return rc; } +int xc_altp2m_set_supress_ve_multi(xc_interface *handle, uint32_t domid, + uint16_t view_id, xen_pfn_t first_gfn, + xen_pfn_t last_gfn, bool sve, + xen_pfn_t *error_gfn, uint32_t *error_code) +{ + int rc; + DECLARE_HYPERCALL_BUFFER(xen_hvm_altp2m_op_t, arg); + + arg = xc_hypercall_buffer_alloc(handle, arg, sizeof(*arg)); + if ( arg == NULL ) + return -1; + + arg->version = HVMOP_ALTP2M_INTERFACE_VERSION; + arg->cmd = HVMOP_altp2m_set_suppress_ve_multi; + arg->domain = domid; + arg->u.suppress_ve_multi.view = view_id; + arg->u.suppress_ve_multi.first_gfn = first_gfn; + arg->u.suppress_ve_multi.last_gfn = last_gfn; + arg->u.suppress_ve_multi.suppress_ve = sve; + + rc = xencall2(handle->xcall, __HYPERVISOR_hvm_op, HVMOP_altp2m, + HYPERCALL_BUFFER_AS_ARG(arg)); + + if ( arg->u.suppress_ve_multi.first_error ) + { + *error_gfn = arg->u.suppress_ve_multi.first_error; + *error_code = arg->u.suppress_ve_multi.first_error_code; + } + + xc_hypercall_buffer_free(handle, arg); + return rc; +} + int xc_altp2m_set_mem_access(xc_interface *handle, uint32_t domid, uint16_t view_id, xen_pfn_t gfn, xenmem_access_t access) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 47573f71b8..a129049d6b 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4553,6 +4553,7 @@ static int do_altp2m_op( case HVMOP_altp2m_destroy_p2m: case HVMOP_altp2m_switch_p2m: case HVMOP_altp2m_set_suppress_ve: + case HVMOP_altp2m_set_suppress_ve_multi: case HVMOP_altp2m_get_suppress_ve: case HVMOP_altp2m_set_mem_access: case HVMOP_altp2m_set_mem_access_multi: @@ -4711,6 +4712,20 @@ static int do_altp2m_op( } break; + case HVMOP_altp2m_set_suppress_ve_multi: + if ( a.u.suppress_ve_multi.pad1 || + a.u.suppress_ve_multi.first_error_code || + a.u.suppress_ve_multi.first_error || + a.u.suppress_ve_multi.first_gfn > a.u.suppress_ve_multi.last_gfn ) + rc = -EINVAL; + else + { + rc = p2m_set_suppress_ve_multi(d, &a.u.suppress_ve_multi); + if ( (!rc || rc == -ERESTART) && __copy_to_guest(arg, &a, 1) ) + rc = -EFAULT; + } + break; + case HVMOP_altp2m_get_suppress_ve: if ( a.u.suppress_ve.pad1 || a.u.suppress_ve.pad2 ) rc = -EINVAL; diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 7e7f4f1a7c..253cab3458 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -3064,6 +3064,70 @@ out: return rc; } +/* + * Set/clear the #VE suppress bit for multiple pages. Only available on VMX. + */ +int p2m_set_suppress_ve_multi(struct domain *d, + struct xen_hvm_altp2m_suppress_ve_multi *sve) +{ + struct p2m_domain *host_p2m = p2m_get_hostp2m(d); + struct p2m_domain *ap2m = NULL; + struct p2m_domain *p2m = host_p2m; + uint64_t start = sve->first_gfn; + int rc = 0; + uint64_t max_phys_addr = (1UL << d->arch.cpuid->extd.maxphysaddr) - 1; + + if ( sve->view > 0 ) + { + if ( sve->view >= MAX_ALTP2M || + d->arch.altp2m_eptp[array_index_nospec(sve->view, MAX_EPTP)] == + mfn_x(INVALID_MFN) ) + return -EINVAL; + + p2m = ap2m = d->arch.altp2m_p2m[array_index_nospec(sve->view, + MAX_ALTP2M)]; + } + + p2m_lock(host_p2m); + + if ( ap2m ) + p2m_lock(ap2m); + + while ( sve->last_gfn >= start && start < max_phys_addr ) + { + p2m_access_t a; + p2m_type_t t; + mfn_t mfn; + int err = 0; + + if ( altp2m_get_effective_entry(p2m, _gfn(start), &mfn, &t, &a, AP2MGET_query) ) + a = p2m->default_access; + + if ( (err = p2m->set_entry(p2m, _gfn(start), mfn, PAGE_ORDER_4K, t, a, + sve->suppress_ve)) && !sve->first_error ) + { + sve->first_error = start; /* Save the gfn of the first error */ + sve->first_error_code = err; /* Save the first error code */ + } + + /* Check for continuation if it's not the last iteration. */ + if ( sve->last_gfn >= ++start && hypercall_preempt_check() ) + { + rc = -ERESTART; + break; + } + } + + sve->first_gfn = start; + + if ( ap2m ) + p2m_unlock(ap2m); + + p2m_unlock(host_p2m); + + return rc; +} + int p2m_get_suppress_ve(struct domain *d, gfn_t gfn, bool *suppress_ve, unsigned int altp2m_idx) { diff --git a/xen/include/public/hvm/hvm_op.h b/xen/include/public/hvm/hvm_op.h index 353f8034d9..49965d256c 100644 --- a/xen/include/public/hvm/hvm_op.h +++ b/xen/include/public/hvm/hvm_op.h @@ -46,6 +46,16 @@ struct xen_hvm_altp2m_suppress_ve { uint64_t gfn; }; +struct xen_hvm_altp2m_suppress_ve_multi { + uint16_t view; + uint8_t suppress_ve; /* Boolean type. */ + uint8_t pad1; + uint32_t first_error_code; /* Must be set to 0 . */ + uint64_t first_gfn; /* Value will be updated */ + uint64_t last_gfn; + uint64_t first_error; /* Gfn of the first error. Must be set to 0. */ +}; + #if __XEN_INTERFACE_VERSION__ < 0x00040900 /* Set the logical level of one of a domain's PCI INTx wires. */ @@ -339,6 +349,8 @@ struct xen_hvm_altp2m_op { #define HVMOP_altp2m_vcpu_disable_notify 13 /* Get the active vcpu p2m index */ #define HVMOP_altp2m_get_p2m_idx 14 +/* Set the "Supress #VE" bit for a range of pages */ +#define HVMOP_altp2m_set_suppress_ve_multi 15 domid_t domain; uint16_t pad1; uint32_t pad2; @@ -353,6 +365,7 @@ struct xen_hvm_altp2m_op { struct xen_hvm_altp2m_change_gfn change_gfn; struct xen_hvm_altp2m_set_mem_access_multi set_mem_access_multi; struct xen_hvm_altp2m_suppress_ve suppress_ve; + struct xen_hvm_altp2m_suppress_ve_multi suppress_ve_multi; 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]; diff --git a/xen/include/xen/mem_access.h b/xen/include/xen/mem_access.h index e4d24502e0..00e594a0ad 100644 --- a/xen/include/xen/mem_access.h +++ b/xen/include/xen/mem_access.h @@ -75,6 +75,9 @@ long p2m_set_mem_access_multi(struct domain *d, int p2m_set_suppress_ve(struct domain *d, gfn_t gfn, bool suppress_ve, unsigned int altp2m_idx); +int p2m_set_suppress_ve_multi(struct domain *d, + struct xen_hvm_altp2m_suppress_ve_multi *suppress_ve); + int p2m_get_suppress_ve(struct domain *d, gfn_t gfn, bool *suppress_ve, unsigned int altp2m_idx); From patchwork Tue Dec 17 15:12:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexandru Stefan ISAILA X-Patchwork-Id: 11297891 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F6AC1593 for ; Tue, 17 Dec 2019 15:13:50 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EF2C02146E for ; Tue, 17 Dec 2019 15:13:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bitdefender.onmicrosoft.com header.i=@bitdefender.onmicrosoft.com header.b="Y7dOKjYJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF2C02146E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bitdefender.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ihEWq-0008El-OA; Tue, 17 Dec 2019 15:12:52 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ihEWp-0008EM-Al for xen-devel@lists.xenproject.org; Tue, 17 Dec 2019 15:12:51 +0000 X-Inumbo-ID: ac1f9af8-20df-11ea-b6f1-bc764e2007e4 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (unknown [40.107.5.102]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ac1f9af8-20df-11ea-b6f1-bc764e2007e4; Tue, 17 Dec 2019 15:12:42 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UsqQ+JVzdelMk0G3Moh1xKAmfnKsezG16wWxRv/mqjT3V6s2GNwUqgNT+lpp4SZpq2doC/OIMysd4ppbyqYrx/VfZhprsIiHvlJGlOaRrL4lBtr6j4KY9+IosqGWAV1EuDzu70MfKSQ48uqiMHy41joCZpN7LjbP9JDokV1bQdeMKVZ8m+Y2M2KSKnc8fLYohKy9CD8n+/Y12lpTK1GC8jsV2WCVD6BJSCZ54lVS7H5gO4IsVWB3BtKDpBQX9I6i44cBm9lsYNgyy4d4dgRzz3ynS2JdAtjOqaP3w1sLmklcYS6yB5wPU9pCVl6Ne5hcEC1fYVxDLDbHAmjACglAJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oQQcj/kCLuqhEOjPzK84oKJ2erIYwHMpYTAxWNLBGWk=; b=E6pimmRW2Xk6NXhv8fQkEsbdZfI93flSsEdqhhdYiXQY/6ZMPzK/sr6f9ITblpDFrhlmP4BtZkAYFo1xzzSd2s6ziav2lgYS75uEl/iiUJkFtOT5ORsA5JiwaSsp90ftLrchYoJk3idKNdGJaWNlXbPv9AGh5vwxLWfVmByCV5a0DN77OffXEedL/Y87K+kKtd2nj53EoxCIZqEK9xqRHDtDOLM5vHFKlTMuPyoe8FNdAVlNRovc6UwQu4mOkEnCy6v5Cw1oSE8LagCEQ/UZ9rE0aeAQf1HQmwveWAMA8GCkRSufPY38641qL0AUr2kA8br2R3Tvctz0uBZrGZ6z4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bitdefender.com; dmarc=pass action=none header.from=bitdefender.com; dkim=pass header.d=bitdefender.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bitdefender.onmicrosoft.com; s=selector2-bitdefender-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oQQcj/kCLuqhEOjPzK84oKJ2erIYwHMpYTAxWNLBGWk=; b=Y7dOKjYJJF5FwSMiO13NJpsd8Yri4gT2C2k6jXt/RpFvg6bycBzZ/DStHEhyHYFo99o1z9zLibHaS78rNwLPwbovGtADgKEVA6MKtQEqok3C7h8WVvBia3fq6VJBcjdPAY4TtP7DNMN2MD9GndKt7zAS4Ww4IpnMQI0pmA+fHWE= Received: from AM0PR02MB5553.eurprd02.prod.outlook.com (10.255.30.78) by AM0PR02MB4386.eurprd02.prod.outlook.com (20.178.17.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2538.20; Tue, 17 Dec 2019 15:12:35 +0000 Received: from AM0PR02MB5553.eurprd02.prod.outlook.com ([fe80::8cec:7638:734c:89d]) by AM0PR02MB5553.eurprd02.prod.outlook.com ([fe80::8cec:7638:734c:89d%4]) with mapi id 15.20.2538.019; Tue, 17 Dec 2019 15:12:35 +0000 From: Alexandru Stefan ISAILA To: "xen-devel@lists.xenproject.org" Thread-Topic: [PATCH V4 3/4] x86/mm: Pull out the p2m specifics from p2m_init_altp2m_ept Thread-Index: AQHVtOxpSoGNE4L+skG6HNN4NefFyg== Date: Tue, 17 Dec 2019 15:12:34 +0000 Message-ID: <20191217151144.9781-3-aisaila@bitdefender.com> References: <20191217151144.9781-1-aisaila@bitdefender.com> In-Reply-To: <20191217151144.9781-1-aisaila@bitdefender.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM0PR01CA0067.eurprd01.prod.exchangelabs.com (2603:10a6:208:e6::44) To AM0PR02MB5553.eurprd02.prod.outlook.com (2603:10a6:208:160::14) 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: c1a01afe-51c6-4cc6-89c2-08d783038bb2 x-ms-traffictypediagnostic: AM0PR02MB4386:|AM0PR02MB4386:|AM0PR02MB4386: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:243; x-forefront-prvs: 02543CD7CD x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(136003)(396003)(39860400002)(346002)(376002)(189003)(199004)(6512007)(52116002)(64756008)(86362001)(186003)(8936002)(6486002)(4326008)(2906002)(54906003)(66476007)(71200400001)(66556008)(66946007)(36756003)(26005)(81156014)(81166006)(5660300002)(8676002)(6506007)(478600001)(66446008)(1076003)(2616005)(316002)(6916009); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR02MB4386; H:AM0PR02MB5553.eurprd02.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: bitdefender.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: e4pRuDFPAcL6s+eDgRdWK3fVdAhp9PxWUVaUrBJ8R5xNELg4IptDimz7SKD228T4Mpu6Womhg+nTd26dw3AwKmKNSXgG73rYgL4fZQXMe3Ncf7gxEARtqag0B9o6wgkEtiQI0iEKr6169waPvlC/h48IFkK/rSvQq99igiuHkuqsAaoTPgkcNt0hV4ufdfedgvdTCut3dH8xZEiKaNyYAVcHuFIgDZHatGAcTxt1gxbD6/BMAPepgbakhrLvuuZQNawEBVh/CAKMJmTbvyHiDYPtvsi41b2HIFmIZCZ5TNafvWgOMb0HEk8psx2STVw6EmY2cxld+RSTsx+Ywh9OIC4vTHpjh1pgoBVbmopuZh+KRepkpyfc5Fyw4bN51UGiji+AnyNUCfrunjJ07uwzGbd97E1nDKfjVP8HKcPFwe7rEI/wPtjMN184qVNLhgbB Content-ID: <6723024B440EC240AB191EC15FBD9BD3@eurprd02.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: bitdefender.com X-MS-Exchange-CrossTenant-Network-Message-Id: c1a01afe-51c6-4cc6-89c2-08d783038bb2 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Dec 2019 15:12:34.9937 (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: AIk4KbwPHZV1QNglVJtBdgpq7WvRljvY6i1yFB0WJcRsn/GofL6SYt8pNdcGp0kqrHAE8UHto4fQoDcD/9yAsno8UxJeFIXN5kZFObrfYm0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR02MB4386 Subject: [Xen-devel] [PATCH V4 3/4] x86/mm: Pull out the p2m specifics from p2m_init_altp2m_ept 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: Kevin Tian , Jun Nakajima , Wei Liu , George Dunlap , Andrew Cooper , Jan Beulich , Alexandru Stefan ISAILA , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Signed-off-by: Alexandru Isaila Reviewed-by: Jan Beulich --- CC: Jun Nakajima CC: Kevin Tian CC: George Dunlap CC: Jan Beulich CC: Andrew Cooper CC: Wei Liu CC: "Roger Pau Monné" --- xen/arch/x86/mm/p2m-ept.c | 6 ------ xen/arch/x86/mm/p2m.c | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index e088a63f56..362f7079ab 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -1358,13 +1358,7 @@ void p2m_init_altp2m_ept(struct domain *d, unsigned int i) struct p2m_domain *hostp2m = p2m_get_hostp2m(d); struct ept_data *ept; - p2m->default_access = hostp2m->default_access; - p2m->domain = hostp2m->domain; - - p2m->global_logdirty = hostp2m->global_logdirty; p2m->ept.ad = hostp2m->ept.ad; - p2m->min_remapped_gfn = gfn_x(INVALID_GFN); - p2m->max_mapped_pfn = p2m->max_remapped_gfn = 0; ept = &p2m->ept; ept->mfn = pagetable_get_pfn(p2m_get_pagetable(p2m)); d->arch.altp2m_eptp[array_index_nospec(i, MAX_EPTP)] = ept->eptp; diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 253cab3458..d381f6877f 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -2559,6 +2559,12 @@ static int p2m_activate_altp2m(struct domain *d, unsigned int idx) goto out; } + p2m->default_access = hostp2m->default_access; + p2m->domain = hostp2m->domain; + p2m->global_logdirty = hostp2m->global_logdirty; + p2m->min_remapped_gfn = gfn_x(INVALID_GFN); + p2m->max_mapped_pfn = p2m->max_remapped_gfn = 0; + p2m_init_altp2m_ept(d, idx); out: From patchwork Tue Dec 17 15:12:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexandru Stefan ISAILA X-Patchwork-Id: 11297893 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5008C112B for ; Tue, 17 Dec 2019 15:14:12 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1F8A3218AC for ; Tue, 17 Dec 2019 15:14:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=bitdefender.onmicrosoft.com header.i=@bitdefender.onmicrosoft.com header.b="SJzY8O46" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F8A3218AC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bitdefender.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ihEX0-0008I8-6w; Tue, 17 Dec 2019 15:13:02 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ihEWy-0008Hc-Bu for xen-devel@lists.xenproject.org; Tue, 17 Dec 2019 15:13:00 +0000 X-Inumbo-ID: b159e5a0-20df-11ea-b6f1-bc764e2007e4 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (unknown [40.107.5.102]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id b159e5a0-20df-11ea-b6f1-bc764e2007e4; Tue, 17 Dec 2019 15:12:51 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nJS4Eg07+fBcFtVTgBMretvZBZ7ai7dElJStp/MAL9oJ8+iB70l/Zxt8hw4ZX8W3TzIlTV0s+ZGJLKo6DdZMh+Yel5G43A3U5iZRcwv5mufJzyboyy7lUJd+IMB87Ea3hZn5uVq1SdYNsw4QBD4DzyhbSY+k600PvyVcfqp+lekbkMlaatKwQq+K/lu/IKZGMrvsVSBsygz6c8zpTY1067vo+sLfsQGuZICpGr6kY27kQCIIg9A2zcM29YeguxBqsCvVC+mlCIuV99W1g7aHNID45rFvu7bfFqCShCIeV0Gf65o5UHH1ZoWE7b9OCLiE0ezffX6c/XsOIdF43tKyDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pqkvd75hAcc26QVUyyPpG1tYUVnE9+PL69gAybNnLdA=; b=VDTi2LdWW/cfC3qOdvTUtDAvVl60wCVeHTRm7lVnQwASjS67cFNNHis55Bt2hLBPINwpXppbF3mr5FXdULs1Kelw27GxlCYg3JrCEFptg3alhf8zlm5i+Ih9faz9mR+YPKJtQJSsbVObKWsGUc9KKBWeAEkWqt4p0/HODlVnZjzk8EViTHWX6tjx2Ba7f44+8xE7OvH9KCjNEfcc2RdTicIta3JqWxqg30Np5URM2F6FzULO/c2X88w9IF+hQLIDG1/6qVaMaffAMOimePecNLG6M2ptP6p6QOaLkD7bLPdxfjvHcecgXBzBOfj6Jouv4SJKEAoXQecqQQorC9pqWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bitdefender.com; dmarc=pass action=none header.from=bitdefender.com; dkim=pass header.d=bitdefender.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bitdefender.onmicrosoft.com; s=selector2-bitdefender-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pqkvd75hAcc26QVUyyPpG1tYUVnE9+PL69gAybNnLdA=; b=SJzY8O46wxhm6Jsj5Mxye+NAWUD7A4ycu6e3BYAEIyOyDXrbqEzKcZy42BHOQgxfcxwmcENQExMGk1fX1q7W/JPCEQwoIpDjabV22TEU09Gs1v04JIdhdH4cmWKInsVRqCmuLsui2qH4evqXp8jE11zosyq3jslT+XBkQl5KApg= Received: from AM0PR02MB5553.eurprd02.prod.outlook.com (10.255.30.78) by AM0PR02MB4386.eurprd02.prod.outlook.com (20.178.17.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2538.20; Tue, 17 Dec 2019 15:12:42 +0000 Received: from AM0PR02MB5553.eurprd02.prod.outlook.com ([fe80::8cec:7638:734c:89d]) by AM0PR02MB5553.eurprd02.prod.outlook.com ([fe80::8cec:7638:734c:89d%4]) with mapi id 15.20.2538.019; Tue, 17 Dec 2019 15:12:42 +0000 From: Alexandru Stefan ISAILA To: "xen-devel@lists.xenproject.org" Thread-Topic: [PATCH V4 4/4] x86/mm: Make use of the default access param from xc_altp2m_create_view Thread-Index: AQHVtOxtPhIY/fNOfU26Nr2n4YFnQg== Date: Tue, 17 Dec 2019 15:12:41 +0000 Message-ID: <20191217151144.9781-4-aisaila@bitdefender.com> References: <20191217151144.9781-1-aisaila@bitdefender.com> In-Reply-To: <20191217151144.9781-1-aisaila@bitdefender.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM0PR01CA0067.eurprd01.prod.exchangelabs.com (2603:10a6:208:e6::44) To AM0PR02MB5553.eurprd02.prod.outlook.com (2603:10a6:208:160::14) 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: d1c7465d-82bc-4165-5826-08d783038fd7 x-ms-traffictypediagnostic: AM0PR02MB4386:|AM0PR02MB4386:|AM0PR02MB4386: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2582; x-forefront-prvs: 02543CD7CD x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(136003)(396003)(39860400002)(346002)(376002)(189003)(199004)(7416002)(6512007)(52116002)(64756008)(86362001)(186003)(8936002)(6486002)(4326008)(2906002)(54906003)(66476007)(71200400001)(66556008)(66946007)(36756003)(26005)(81156014)(81166006)(5660300002)(8676002)(6506007)(478600001)(66446008)(1076003)(2616005)(316002)(6916009); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR02MB4386; H:AM0PR02MB5553.eurprd02.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: bitdefender.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Hvb8sdyrmFVpHcpMuHblM/GFZ0y7JsgE8e6hrXWrE4pUL+DhxOXTPUUCf7szvpsA//KDM+hj2zVlUcgVXlceThYKX3r1+jMqWZK/B9bRwH8IZWMZ/V269Tt343OrxhKK2lfUR+rI6iSlaMz5aZH15Nll1RQrHV2X53yCubu/NCSh/UJsUa6j67SCYJD9bCxS7h05r9i+6oG8kmbL3lZXoIFM76QyWftafbmYdCLhP+UITzbM6TTkDJCFh7nZw7Urdqy1nr00O9idYOlYvUElkq4Kv6nPfeBxST/PuzGJ8xgKOI3s9yQKYpxnxiCgPNEaq/oVjKnFztEuEmfPspAbrDs/ykUzWqUiTN9GWyr2HQPhEGUCi2Cb0wxiP8tS9yfvnq2pg5QWYh/DsAGghxMWRGPD+EtCK9kKOgGlVLB4pFs1Z6wEVqICccitza+vLNND Content-ID: MIME-Version: 1.0 X-OriginatorOrg: bitdefender.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1c7465d-82bc-4165-5826-08d783038fd7 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Dec 2019 15:12:41.8998 (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: PCR1X1DxL4hxn9Ih2pTkoY5HjUOuRUi2ixtjHso5vquAQESEKZvoKD/WR3CjE8wyFMnPPpeiXWFLyVTvpjnnSuL388r8QMGazJuBSJQ1zTQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR02MB4386 Subject: [Xen-devel] [PATCH V4 4/4] x86/mm: Make use of the default access param from xc_altp2m_create_view 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: Petre Ovidiu PIRCALABU , Stefano Stabellini , Julien Grall , Razvan COJOCARU , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tamas K Lengyel , Jan Beulich , Alexandru Stefan ISAILA , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" At this moment the default_access param from xc_altp2m_create_view is not used. This patch assigns default_access to p2m->default_access at the time of initializing a new altp2m view. Signed-off-by: Alexandru Isaila --- CC: Jan Beulich CC: Andrew Cooper CC: Wei Liu CC: "Roger Pau Monné" CC: George Dunlap CC: Ian Jackson CC: Julien Grall CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Razvan Cojocaru CC: Tamas K Lengyel CC: Petre Pircalabu CC: George Dunlap --- Changes since V3: - Change type of hvmmem_default_access to xenmem_access_t - Fix style issues - Release lock before return. --- xen/arch/x86/hvm/hvm.c | 3 ++- xen/arch/x86/mm/mem_access.c | 6 +++--- xen/arch/x86/mm/p2m.c | 27 ++++++++++++++++++++++----- xen/include/asm-x86/p2m.h | 3 ++- xen/include/public/hvm/hvm_op.h | 2 -- xen/include/xen/mem_access.h | 4 ++++ 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index a129049d6b..d4b19d2412 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4687,7 +4687,8 @@ static int do_altp2m_op( } case HVMOP_altp2m_create_p2m: - if ( !(rc = p2m_init_next_altp2m(d, &a.u.view.view)) ) + if ( !(rc = p2m_init_next_altp2m(d, &a.u.view.view, + a.u.view.hvmmem_default_access)) ) rc = __copy_to_guest(arg, &a, 1) ? -EFAULT : 0; break; diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c index 70f3528bb1..288c865ffa 100644 --- a/xen/arch/x86/mm/mem_access.c +++ b/xen/arch/x86/mm/mem_access.c @@ -314,9 +314,9 @@ static int set_mem_access(struct domain *d, struct p2m_domain *p2m, return rc; } -static bool xenmem_access_to_p2m_access(struct p2m_domain *p2m, - xenmem_access_t xaccess, - p2m_access_t *paccess) +bool xenmem_access_to_p2m_access(struct p2m_domain *p2m, + xenmem_access_t xaccess, + p2m_access_t *paccess) { static const p2m_access_t memaccess[] = { #define ACCESS(ac) [XENMEM_access_##ac] = p2m_access_##ac diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index d381f6877f..d67326f8b7 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -25,6 +25,7 @@ #include /* copy_from_guest() */ #include +#include #include #include #include @@ -2533,7 +2534,8 @@ void p2m_flush_altp2m(struct domain *d) altp2m_list_unlock(d); } -static int p2m_activate_altp2m(struct domain *d, unsigned int idx) +static int p2m_activate_altp2m(struct domain *d, unsigned int idx, + p2m_access_t hvmmem_default_access) { struct p2m_domain *hostp2m, *p2m; int rc; @@ -2559,7 +2561,7 @@ static int p2m_activate_altp2m(struct domain *d, unsigned int idx) goto out; } - p2m->default_access = hostp2m->default_access; + p2m->default_access = hvmmem_default_access; p2m->domain = hostp2m->domain; p2m->global_logdirty = hostp2m->global_logdirty; p2m->min_remapped_gfn = gfn_x(INVALID_GFN); @@ -2576,6 +2578,7 @@ static int p2m_activate_altp2m(struct domain *d, unsigned int idx) int p2m_init_altp2m_by_id(struct domain *d, unsigned int idx) { int rc = -EINVAL; + struct p2m_domain *hostp2m = p2m_get_hostp2m(d); if ( idx >= MAX_ALTP2M ) return rc; @@ -2583,16 +2586,22 @@ int p2m_init_altp2m_by_id(struct domain *d, unsigned int idx) altp2m_list_lock(d); if ( d->arch.altp2m_eptp[idx] == mfn_x(INVALID_MFN) ) - rc = p2m_activate_altp2m(d, idx); + rc = p2m_activate_altp2m(d, idx, hostp2m->default_access); altp2m_list_unlock(d); return rc; } -int p2m_init_next_altp2m(struct domain *d, uint16_t *idx) +int p2m_init_next_altp2m(struct domain *d, uint16_t *idx, + xenmem_access_t hvmmem_default_access) { int rc = -EINVAL; unsigned int i; + p2m_access_t a; + struct p2m_domain *p2m; + + if ( hvmmem_default_access > XENMEM_access_default ) + return rc; altp2m_list_lock(d); @@ -2601,7 +2610,15 @@ int p2m_init_next_altp2m(struct domain *d, uint16_t *idx) if ( d->arch.altp2m_eptp[i] != mfn_x(INVALID_MFN) ) continue; - rc = p2m_activate_altp2m(d, i); + p2m = d->arch.altp2m_p2m[i]; + + if ( !xenmem_access_to_p2m_access(p2m, hvmmem_default_access, &a) ) + { + altp2m_list_unlock(d); + return -EINVAL; + } + + rc = p2m_activate_altp2m(d, i, a); if ( !rc ) *idx = i; diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 94285db1b4..ac2d2787f4 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -884,7 +884,8 @@ bool p2m_altp2m_get_or_propagate(struct p2m_domain *ap2m, unsigned long gfn_l, int p2m_init_altp2m_by_id(struct domain *d, unsigned int idx); /* Find an available alternate p2m and make it valid */ -int p2m_init_next_altp2m(struct domain *d, uint16_t *idx); +int p2m_init_next_altp2m(struct domain *d, uint16_t *idx, + xenmem_access_t hvmmem_default_access); /* Make a specific alternate p2m invalid */ int p2m_destroy_altp2m_by_id(struct domain *d, unsigned int idx); diff --git a/xen/include/public/hvm/hvm_op.h b/xen/include/public/hvm/hvm_op.h index 49965d256c..2599887f7f 100644 --- a/xen/include/public/hvm/hvm_op.h +++ b/xen/include/public/hvm/hvm_op.h @@ -251,8 +251,6 @@ DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_vcpu_disable_notify_t); struct xen_hvm_altp2m_view { /* IN/OUT variable */ uint16_t view; - /* Create view only: default access type - * NOTE: currently ignored */ uint16_t hvmmem_default_access; /* xenmem_access_t */ }; typedef struct xen_hvm_altp2m_view xen_hvm_altp2m_view_t; diff --git a/xen/include/xen/mem_access.h b/xen/include/xen/mem_access.h index 00e594a0ad..dc6afc7252 100644 --- a/xen/include/xen/mem_access.h +++ b/xen/include/xen/mem_access.h @@ -58,6 +58,10 @@ typedef enum { /* NOTE: Assumed to be only 4 bits right now on x86. */ } p2m_access_t; +bool xenmem_access_to_p2m_access(struct p2m_domain *p2m, + xenmem_access_t xaccess, + p2m_access_t *paccess); + /* * Set access type for a region of gfns. * If gfn == INVALID_GFN, sets the default access type.