From patchwork Wed Jan 8 14:08:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexandru Stefan ISAILA X-Patchwork-Id: 11323753 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 BD601109A for ; Wed, 8 Jan 2020 14:09:56 +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 8DD5A20643 for ; Wed, 8 Jan 2020 14:09:56 +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="gcWB6tVj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8DD5A20643 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 1ipC0l-000438-NI; Wed, 08 Jan 2020 14:08:39 +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 1ipC0j-000433-Vp for xen-devel@lists.xenproject.org; Wed, 08 Jan 2020 14:08:38 +0000 X-Inumbo-ID: 5c034b12-3220-11ea-b7ff-12813bfff9fa Received: from EUR05-VI1-obe.outbound.protection.outlook.com (unknown [40.107.21.136]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5c034b12-3220-11ea-b7ff-12813bfff9fa; Wed, 08 Jan 2020 14:08:36 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IrAKZkkyIq/tp5LJonPYh4zjxHe7jC9fR9ygtqHUJbEf0SorgfQDUhgX4PZ7nwYariTZ9rjU4l4KqHwtEg1PQv5Izo8zP7NYUujjioSKjGlKJ8J1YH8slBwhJRRZ9ewbnntX60iN03RSv52mKyA/0svQGZLxVaySovbBWOfzyyM0GdlurPEGiHDlOjdUJbg2GG3cQuWvQtp+I0m3x+ooj4quwn1m1y/HtaNO0HgCoVS3ZlMnaPohpOadWB4Fx+CpbuCjM0ZqJq6xCTKzLn4q73S0sVeB2oevvarmlnTYgnv77tePLlFHcIgVkmyI805Bu/lmm8987L+72XZEKOfLpg== 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=eePxzpxYo/MhwmgzdiCnxuBgi2bP92P+EChzn6tAxik=; b=BeOtDtVEKY1/2GEEYzpG78dEqeB13rWUdwwCaPnkrtLuZ70MHC+sghcJGinCG03J5NPsrnWNy/Meap6huir97hLm1aruPb+ySSAe5bsyd/OFH4lz38liyKI3Mz5QyJ3E+2ThlFDTagKLbqstRAnRqFbS2TkstGkIyKbEsnRtv9/+BxQiTR1tmR+XwWCGqycBFHKN1+2P7EnZZ4LlfEE2gftz8YVbZAFgIytuIrwLVOOxEaqV1RoQmeuduw/CL/xOFlvW9IQ6HhVK19NRFkI9lFVgyGHvrxZHs2G26NuIgQQrRpSsYjX5XQzRWYRj7R/1FI7qplDLXDSKzEY13J/nHQ== 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=eePxzpxYo/MhwmgzdiCnxuBgi2bP92P+EChzn6tAxik=; b=gcWB6tVj3Ti+h4hI+55N+DC74O1njRX+V3qgHhX7fMx7Np5uqC1KODNzw2xrFiTCsxgrs1lgVEd19eS1VL/M1E0cFhAbCV1jccoUCZleJ6IfZFRvJo05uwjOjDkhsSU4dwmGAHB2LRJidvj5BTKkhqPnZvB64RKll5qV7rWmT6o= Received: from DB6PR02MB2999.eurprd02.prod.outlook.com (10.170.219.144) by DB6PR02MB3253.eurprd02.prod.outlook.com (10.170.221.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.12; Wed, 8 Jan 2020 14:08:34 +0000 Received: from DB6PR02MB2999.eurprd02.prod.outlook.com ([fe80::f1c2:7dd1:1131:1c1d]) by DB6PR02MB2999.eurprd02.prod.outlook.com ([fe80::f1c2:7dd1:1131:1c1d%7]) with mapi id 15.20.2623.008; Wed, 8 Jan 2020 14:08:34 +0000 Received: from aisaila-Latitude-E5570.dsd.bitdefender.biz (91.199.104.6) by AM4PR05CA0023.eurprd05.prod.outlook.com (2603:10a6:205::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2623.9 via Frontend Transport; Wed, 8 Jan 2020 14:08:33 +0000 From: Alexandru Stefan ISAILA To: "xen-devel@lists.xenproject.org" Thread-Topic: [PATCH V7 1/4] x86/mm: Add array_index_nospec to guest provided index values Thread-Index: AQHVxi0djSZfDHZ8NkyVFOFmjVTSAQ== Date: Wed, 8 Jan 2020 14:08:34 +0000 Message-ID: <20200108140810.6528-1-aisaila@bitdefender.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM4PR05CA0023.eurprd05.prod.outlook.com (2603:10a6:205::36) To DB6PR02MB2999.eurprd02.prod.outlook.com (2603:10a6:6:17::16) 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: 03f8ea97-20cc-4620-dd44-08d794443f6c x-ms-traffictypediagnostic: DB6PR02MB3253:|DB6PR02MB3253: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1002; x-forefront-prvs: 02760F0D1C x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(396003)(376002)(346002)(366004)(39850400004)(189003)(199004)(66446008)(16526019)(4326008)(66556008)(54906003)(8676002)(81156014)(66476007)(316002)(64756008)(81166006)(2906002)(6506007)(6512007)(6916009)(52116002)(26005)(186003)(66946007)(5660300002)(8936002)(36756003)(1076003)(956004)(2616005)(86362001)(478600001)(6486002)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR02MB3253; H:DB6PR02MB2999.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: oua2/h5wsv3DP9VbaM+prT0foeaawrp9jOGBOJp7hJmex+uuCDmdMSHiVwfPLeGimK3UYwg0qVblZs4mJa8NYJvfU5mTbLzqK3V9Zl4sPtfl3x0DUJfxbM6uC/p+IGkOJ8IEf8VgntLNNRWmqOn7OTw3F7bFrqJllx4Lfl/Cfjtj+emabrsEH+5FIpqZBnh83brBe19eDU80Dp2o374x+2XepsFiezrwVPp80j6UprfTl4ukTl8Eh9wNR8rpaygvTD9GqTDkukcktMxmt/EpSWBRhfE1YUNBWpXPRUYFr3/7FptwsbU8Uul9tFQpK6ZJobvVfKxoRg1YN7W9ABwe14AKg2cBT9xTR9jgEvP1olAdk7LyZMRk7lc8du9m7IrEU0OX5Sbg5eCOu/e+1b+EXUdjdPbzeglmAv8vp7LOCq4T81Vk96dvPHs+At9WeRHs Content-ID: <2C8B672076B90E4DA8CFB3165843465D@eurprd02.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: bitdefender.com X-MS-Exchange-CrossTenant-Network-Message-Id: 03f8ea97-20cc-4620-dd44-08d794443f6c X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jan 2020 14:08:34.0719 (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: lO+nZy7Kf0UyuLttj5uwZ5tJoAdgde++gqmBWnvQGM1AgnZsforjP8Z9DmrbcSgwThpm0QspeWoWti+2MK+PJOVJBJx7UM9/JD3mrHXWFJE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR02MB3253 Subject: [Xen-devel] [PATCH V7 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. Requested-by: Jan Beulich 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 --- Changes since V6: - Remove stray spaces - Use ARRAY_SIZE(d->arch.altp2m_p2m) insead of MAX_ALTP2M. --- xen/arch/x86/mm/mem_access.c | 24 +++++++++++-------- xen/arch/x86/mm/p2m-ept.c | 6 +++-- xen/arch/x86/mm/p2m.c | 45 +++++++++++++++++++++++------------- 3 files changed, 48 insertions(+), 27 deletions(-) diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c index 320b9fe621..f323d885b1 100644 --- a/xen/arch/x86/mm/mem_access.c +++ b/xen/arch/x86/mm/mem_access.c @@ -366,11 +366,13 @@ long p2m_set_mem_access(struct domain *d, gfn_t gfn, uint32_t nr, #ifdef CONFIG_HVM if ( altp2m_idx ) { - if ( altp2m_idx >= MAX_ALTP2M || - d->arch.altp2m_eptp[altp2m_idx] == mfn_x(INVALID_MFN) ) + if ( altp2m_idx >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || + 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, + ARRAY_SIZE(d->arch.altp2m_p2m))]; } #else ASSERT(!altp2m_idx); @@ -425,11 +427,13 @@ long p2m_set_mem_access_multi(struct domain *d, #ifdef CONFIG_HVM if ( altp2m_idx ) { - if ( altp2m_idx >= MAX_ALTP2M || - d->arch.altp2m_eptp[altp2m_idx] == mfn_x(INVALID_MFN) ) + if ( altp2m_idx >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || + 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, + ARRAY_SIZE(d->arch.altp2m_p2m))]; } #else ASSERT(!altp2m_idx); @@ -491,11 +495,13 @@ 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) ) + if ( altp2m_idx >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || + 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, + ARRAY_SIZE(d->arch.altp2m_p2m))]; } #else ASSERT(!altp2m_idx); diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index b5517769c9..1c23ea6169 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -1353,7 +1353,9 @@ 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, + ARRAY_SIZE(d->arch.altp2m_p2m))]; struct p2m_domain *hostp2m = p2m_get_hostp2m(d); struct ept_data *ept; @@ -1366,7 +1368,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 3119269073..5f046960a9 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -2502,7 +2502,8 @@ 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, + ARRAY_SIZE(d->arch.altp2m_p2m))]; p2m_lock(p2m); @@ -2543,7 +2544,8 @@ 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, + ARRAY_SIZE(d->arch.altp2m_p2m))]; hostp2m = p2m_get_hostp2m(d); p2m_lock(p2m); @@ -2574,12 +2576,13 @@ int p2m_init_altp2m_by_id(struct domain *d, unsigned int idx) { int rc = -EINVAL; - if ( idx >= MAX_ALTP2M ) + if ( idx >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) ) return rc; 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) ) rc = p2m_activate_altp2m(d, idx); altp2m_list_unlock(d); @@ -2615,7 +2618,7 @@ int p2m_destroy_altp2m_by_id(struct domain *d, unsigned int idx) struct p2m_domain *p2m; int rc = -EBUSY; - if ( !idx || idx >= MAX_ALTP2M ) + if ( !idx || idx >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) ) return rc; rc = domain_pause_except_self(d); @@ -2625,14 +2628,17 @@ 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, + ARRAY_SIZE(d->arch.altp2m_p2m))]; if ( !_atomic_read(p2m->active_vcpus) ) { p2m_reset_altp2m(d, idx, ALTP2M_DEACTIVATE); - d->arch.altp2m_eptp[idx] = mfn_x(INVALID_MFN); + d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] = + mfn_x(INVALID_MFN); rc = 0; } } @@ -2689,11 +2695,14 @@ 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 >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || + 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, + ARRAY_SIZE(d->arch.altp2m_p2m))]; p2m_lock(hp2m); p2m_lock(ap2m); @@ -3032,11 +3041,13 @@ 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) ) + if ( altp2m_idx >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || + 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, + ARRAY_SIZE(d->arch.altp2m_p2m))]; } else p2m = host_p2m; @@ -3075,11 +3086,13 @@ 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) ) + if ( altp2m_idx >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || + 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, + ARRAY_SIZE(d->arch.altp2m_p2m))]; } else p2m = host_p2m; From patchwork Wed Jan 8 14:08:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexandru Stefan ISAILA X-Patchwork-Id: 11323749 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 1FCA3109A for ; Wed, 8 Jan 2020 14:09: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 E467820643 for ; Wed, 8 Jan 2020 14:09: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="j+STwuGF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E467820643 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 1ipC0q-00044H-4p; Wed, 08 Jan 2020 14:08:44 +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 1ipC0o-000442-R6 for xen-devel@lists.xenproject.org; Wed, 08 Jan 2020 14:08:42 +0000 X-Inumbo-ID: 5da0a41a-3220-11ea-b7ff-12813bfff9fa Received: from EUR05-VI1-obe.outbound.protection.outlook.com (unknown [40.107.21.116]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5da0a41a-3220-11ea-b7ff-12813bfff9fa; Wed, 08 Jan 2020 14:08:38 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jKuzWmBkta4oQa9hqllOktCmFOI5YFf6yS19Pwnvy5WiA6jl1WOnrdT+qdw/29kxyi843PknCQyaELCaiqSgLJ9dlETpyX8QYAkwJkcgbO2bC3NyJidpaRrg+FIuO38j1s6VFqi5+sasr8HrtI5DOh7GLQZo/QTLHG3DQKy5baH+ComnZQMwr3s9BG/l1rnpd3rB30pkcPNvriyLDE1QJAjMpBiEljp/VMPhjdR+z766JtL+65m2nvIKeau4V30XmCpsdPDFlIf0NKjcNrFOFCZgMp2kLecbyx9Y0Csu45cAgPa2IFEQWMaQFJdvlEZVwyLGTezhL83yKxvC9Wl95g== 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=zJx4eNboYpQPoIh861Sk3aHxNgfwfUAdp2rk3h9Dzn8=; b=R6KCs9DKPklewsyl7IGn8pLv76or3gfE2/q+Aj+hgH1P/p+NhDDV9PkblKMtJorDiO56VLex2Li+mUdY3GY5aA0QxVzCghaaeeqZSspKObRxIk8mrcjIi13hkQ1Ekf9XLTEq9IrveKWLckxVniRBinKHye7h+RbUuuatdSlrFlUOb856pnUtC5Ov8/9OQe7I/CTiskixtfW+XQQKX+rKkzqWm+/9mnXbno/guGPIcoRpdpAx5CpWzU8P7hgvC5FqN0lQNwmXBKOBITJ08Co2hAIWJxNIT+Auo/MPExTXaSvE6m4+evJLAsr0P1MhITQ8DO+Ji1pSKrLZYoTAmT2dzg== 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=zJx4eNboYpQPoIh861Sk3aHxNgfwfUAdp2rk3h9Dzn8=; b=j+STwuGFxmfdL7z0CiEy2dM+I1x70nk1Gdlb5yB/ZK3rX7ndOKIkSMlojOPIPa17SSrSl2EJeXY9EuBHtiZlv/gagRJBiMIvZzFGagx7yIKwoK5tQ169O7+eZs4otSaWuR1d+Zu8FiTyttMleZ8Bz+ltpz8pWWI1+l5hHNbt2uo= Received: from DB6PR02MB2999.eurprd02.prod.outlook.com (10.170.219.144) by DB6PR02MB3253.eurprd02.prod.outlook.com (10.170.221.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.12; Wed, 8 Jan 2020 14:08:36 +0000 Received: from DB6PR02MB2999.eurprd02.prod.outlook.com ([fe80::f1c2:7dd1:1131:1c1d]) by DB6PR02MB2999.eurprd02.prod.outlook.com ([fe80::f1c2:7dd1:1131:1c1d%7]) with mapi id 15.20.2623.008; Wed, 8 Jan 2020 14:08:36 +0000 Received: from aisaila-Latitude-E5570.dsd.bitdefender.biz (91.199.104.6) by AM4PR05CA0023.eurprd05.prod.outlook.com (2603:10a6:205::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2623.9 via Frontend Transport; Wed, 8 Jan 2020 14:08:35 +0000 From: Alexandru Stefan ISAILA To: "xen-devel@lists.xenproject.org" Thread-Topic: [PATCH V7 2/4] x86/altp2m: Add hypercall to set a range of sve bits Thread-Index: AQHVxi0eW7mND/zIzUWDdK2ePPvUVg== Date: Wed, 8 Jan 2020 14:08:36 +0000 Message-ID: <20200108140810.6528-2-aisaila@bitdefender.com> References: <20200108140810.6528-1-aisaila@bitdefender.com> In-Reply-To: <20200108140810.6528-1-aisaila@bitdefender.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM4PR05CA0023.eurprd05.prod.outlook.com (2603:10a6:205::36) To DB6PR02MB2999.eurprd02.prod.outlook.com (2603:10a6:6:17::16) 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: dc49eeda-0e9f-40e9-f627-08d79444410b x-ms-traffictypediagnostic: DB6PR02MB3253:|DB6PR02MB3253: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:121; x-forefront-prvs: 02760F0D1C x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(396003)(376002)(346002)(366004)(39850400004)(189003)(199004)(66446008)(16526019)(4326008)(66556008)(54906003)(8676002)(81156014)(66476007)(316002)(64756008)(81166006)(2906002)(6506007)(6512007)(7416002)(6916009)(52116002)(26005)(186003)(66946007)(5660300002)(8936002)(36756003)(1076003)(956004)(2616005)(107886003)(86362001)(478600001)(6486002)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR02MB3253; H:DB6PR02MB2999.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: Ty66WO7rGUgEn48Ocn5PoqBG9puvdnCpqX6jZl70uhLYCVUtAMpeQATcRTteIMiBgn6epCP+rHrEKPb1KCgJsxnHR7alOscG4MB5lyu5PgzeSU8fYFsMwfWbrrUcWko5PrJAoxPvMUOqZ+8Qy/0eCHGehyVY5iJIjCqqkNm4kZEFHqcTm87pbjnvIyqWT8Yw2snyChQoVP6z9fF1K7fo5yW5isAk+G9VzWBxuy+5xG9vCyRR23/VbWAYJZxDCKV19jA/Jn/0KjTKfpfP/zVEROZ5T2Qh5EPno5w28CY2IEQAG7WQMbMNDVAU5gDAX39Q9XW8kpVPpHYP2uun70eb+yoH/tEZ/0Ie/1e1DoEEo1LDMAWrfmGkHcsB7lMlVFrEb2uWGOfxTTVyjqrWHm2ksz3WPoiFLdYJSq9/FDbS13oq9dApbTXUALdBH+Cyr1Fm Content-ID: MIME-Version: 1.0 X-OriginatorOrg: bitdefender.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc49eeda-0e9f-40e9-f627-08d79444410b X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jan 2020 14:08:36.8193 (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: GxQ5za7hxKicf6zROLAuKYdOpQsD4MRKY5ZsjNxM8GrQGU6o639Oeu8BbD3qCyWiybqStu7m6l9Jj6jY6a9QMN7XX4huwGuVkjOcXfIeAbw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR02MB3253 Subject: [Xen-devel] [PATCH V7 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 break 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 large 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 V6: - Fix commit message - Fix comments from struct xen_hvm_altp2m_suppress_ve_multi - Save the first error from altp2m_get_effective_entry() and skip set_entry() if any error occurred. - Call p2m_set_suppress_ve_multi() in p2m_set_suppress_ve(). --- tools/libxc/include/xenctrl.h | 4 ++ tools/libxc/xc_altp2m.c | 33 ++++++++++++++ xen/arch/x86/hvm/hvm.c | 20 +++++++++ xen/arch/x86/mm/p2m.c | 78 +++++++++++++++++++++++++-------- xen/include/public/hvm/hvm_op.h | 13 ++++++ xen/include/xen/mem_access.h | 3 ++ 6 files changed, 133 insertions(+), 18 deletions(-) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 75f191ae3a..cc4eb1e3d3 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, int32_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..46fb725806 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, int32_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_gfn; + *error_code = arg->u.suppress_ve_multi.first_error; + } + + 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 4723f5d09c..4d79b4934e 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4520,6 +4520,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: @@ -4678,6 +4679,25 @@ static int do_altp2m_op( } break; + case HVMOP_altp2m_set_suppress_ve_multi: + { + uint64_t max_phys_addr = (1UL << d->arch.cpuid->extd.maxphysaddr) - 1; + + a.u.suppress_ve_multi.last_gfn = min(a.u.suppress_ve_multi.last_gfn, + max_phys_addr); + + if ( a.u.suppress_ve_multi.pad1 || + 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 5f046960a9..223ca0cf4c 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -3030,45 +3030,87 @@ out: */ int p2m_set_suppress_ve(struct domain *d, gfn_t gfn, bool suppress_ve, unsigned int altp2m_idx) +{ + int rc; + struct xen_hvm_altp2m_suppress_ve_multi sve = {0}; + + sve.view = altp2m_idx; + sve.suppress_ve = suppress_ve; + sve.first_gfn = gfn_x(gfn); + sve.last_gfn = gfn_x(gfn); + + if ( !(rc = p2m_set_suppress_ve_multi(d, &sve)) && sve.first_error ) + rc = sve.first_error; + + 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; - mfn_t mfn; - p2m_access_t a; - p2m_type_t t; - int rc; + struct p2m_domain *p2m = host_p2m; + uint64_t start = sve->first_gfn; + int rc = 0; - if ( altp2m_idx > 0 ) + if ( sve->view > 0 ) { - if ( altp2m_idx >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || - d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] == + if ( sve->view >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) || + 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(altp2m_idx, + p2m = ap2m = d->arch.altp2m_p2m[array_index_nospec(sve->view, ARRAY_SIZE(d->arch.altp2m_p2m))]; } - else - p2m = host_p2m; - gfn_lock(host_p2m, gfn, 0); + p2m_lock(host_p2m); if ( ap2m ) p2m_lock(ap2m); - rc = altp2m_get_effective_entry(p2m, gfn, &mfn, &t, &a, AP2MGET_query); + while ( sve->last_gfn >= start ) + { + p2m_access_t a; + p2m_type_t t; + mfn_t mfn; + int err = 0; - if ( rc ) - goto out; + if ( (err = altp2m_get_effective_entry(p2m, _gfn(start), &mfn, &t, &a, + AP2MGET_query)) && + !sve->first_error ) + { + sve->first_error_gfn = start; /* Save the gfn of the first error */ + sve->first_error = err; /* Save the first error code */ + } - rc = p2m->set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, t, a, suppress_ve); + if ( !err && (err = p2m->set_entry(p2m, _gfn(start), mfn, + PAGE_ORDER_4K, t, a, + sve->suppress_ve)) && + !sve->first_error ) + { + sve->first_error_gfn = start; /* Save the gfn of the first error */ + sve->first_error = 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; -out: if ( ap2m ) p2m_unlock(ap2m); - gfn_unlock(host_p2m, gfn, 0); + p2m_unlock(host_p2m); return rc; } diff --git a/xen/include/public/hvm/hvm_op.h b/xen/include/public/hvm/hvm_op.h index 353f8034d9..d344606864 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; + int32_t first_error; /* Should be set to 0. */ + uint64_t first_gfn; /* Value may be updated. */ + uint64_t last_gfn; + uint64_t first_error_gfn; /* Gfn of the first error. */ +}; + #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 Wed Jan 8 14:08:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexandru Stefan ISAILA X-Patchwork-Id: 11323757 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 81D3B109A for ; Wed, 8 Jan 2020 14:10:16 +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 5E16820643 for ; Wed, 8 Jan 2020 14:10:16 +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="TB8AuHJM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E16820643 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 1ipC0u-00046i-VD; Wed, 08 Jan 2020 14:08:48 +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 1ipC0t-00046E-R6 for xen-devel@lists.xenproject.org; Wed, 08 Jan 2020 14:08:47 +0000 X-Inumbo-ID: 5ec384ac-3220-11ea-b7ff-12813bfff9fa Received: from EUR05-VI1-obe.outbound.protection.outlook.com (unknown [40.107.21.116]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5ec384ac-3220-11ea-b7ff-12813bfff9fa; Wed, 08 Jan 2020 14:08:40 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ThuAWbuyvaKvZHmtRN8lPCYFAHv8lSQdYqoxHIj0K761/QIZPlMJdefLBP8tmWEdWr02ACf9NG6obY/ky4ZOB9TaB3uHX5x3MIncoPysJeWcRn/zBR39AWK9jzA/gHv+9OMg861utWsLDZG7riRp9unV1R26ss4kU0xMf8XsaW0xwuXM04osWhFazplvc2xhtFwW4H2ns1ZU2n2dWK12JyEP7/icOAGYMkCNgg+zn7e6JR6blxamYzGm8NRAmIJeQqXOMUUpMr/Swpju1WTzcRDhkvTsKHqSbBmV5Yr7NKtBtIfu7N0A3SVpe4FzymVFXlgAdni00lV9VeZDFMpYKw== 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=iV7Etwd85xncHh8h3PvlemQtEvWeXHwIdFtd1Y5jAUI=; b=j/0OY+LgPm+ezbnnCGXqdmU7ak6FM0umGHPMk1Mg1qiWDkf6utOXYpNRKfSgqziKxlngNTE7b0MTiq8FtiRVOLYFssSNZ4GncLFsPXifphi+3z4NP/2AyMuqk5RO1JkFDOkqOQdvPhZ4CS+gHHisJwMMQKxF9KsDzdtLMVW/+hyOo6X6/y0RN0BMMkMLovM5e9Dj1B20l+ZenDUk7P3wGvrAx9JWUCM62pRATU2v0DDQOIx9jkkgGFwyOLrLkRJvWCPNlFE2ZTs0V2SHTHrgeOTsvdWkGLcEZZT5Z6bZPu+bezUShynKFe0exyeH8GdcTSnsCFeDOI5cRnGuw+ZqDQ== 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=iV7Etwd85xncHh8h3PvlemQtEvWeXHwIdFtd1Y5jAUI=; b=TB8AuHJMFY1g1vn4w+nWsDuAENFnHOI7nQey3pibeZf5Lraxs1AzgMettg0jgAK/4fEhfc0PQnceZYWocwssCk3ZuqHWl/EcgItE0Sq9NBRLy/vodhqdKt6Bb0D8jU/Yvm+UAG4/DIiyofjsSHUpuh2uIpTwoRN1IfGWVHREW5c= Received: from DB6PR02MB2999.eurprd02.prod.outlook.com (10.170.219.144) by DB6PR02MB3253.eurprd02.prod.outlook.com (10.170.221.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.12; Wed, 8 Jan 2020 14:08:38 +0000 Received: from DB6PR02MB2999.eurprd02.prod.outlook.com ([fe80::f1c2:7dd1:1131:1c1d]) by DB6PR02MB2999.eurprd02.prod.outlook.com ([fe80::f1c2:7dd1:1131:1c1d%7]) with mapi id 15.20.2623.008; Wed, 8 Jan 2020 14:08:38 +0000 Received: from aisaila-Latitude-E5570.dsd.bitdefender.biz (91.199.104.6) by AM4PR05CA0023.eurprd05.prod.outlook.com (2603:10a6:205::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2623.9 via Frontend Transport; Wed, 8 Jan 2020 14:08:37 +0000 From: Alexandru Stefan ISAILA To: "xen-devel@lists.xenproject.org" Thread-Topic: [PATCH V7 3/4] x86/mm: Pull vendor-independent altp2m code out of p2m-ept.c and into p2m.c Thread-Index: AQHVxi0fbt+nN8/hdEK4zqWI7FQ36A== Date: Wed, 8 Jan 2020 14:08:38 +0000 Message-ID: <20200108140810.6528-3-aisaila@bitdefender.com> References: <20200108140810.6528-1-aisaila@bitdefender.com> In-Reply-To: <20200108140810.6528-1-aisaila@bitdefender.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM4PR05CA0023.eurprd05.prod.outlook.com (2603:10a6:205::36) To DB6PR02MB2999.eurprd02.prod.outlook.com (2603:10a6:6:17::16) 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: 19d1a749-9180-48d0-a6e4-08d7944441ff x-ms-traffictypediagnostic: DB6PR02MB3253:|DB6PR02MB3253: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:243; x-forefront-prvs: 02760F0D1C x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(396003)(376002)(346002)(366004)(39850400004)(189003)(199004)(66446008)(16526019)(4326008)(66556008)(54906003)(8676002)(81156014)(66476007)(316002)(64756008)(81166006)(2906002)(6506007)(6512007)(6916009)(52116002)(26005)(186003)(66946007)(5660300002)(8936002)(36756003)(1076003)(956004)(2616005)(86362001)(478600001)(6486002)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR02MB3253; H:DB6PR02MB2999.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: Zujc8p0vy5Pq2mO0WrvhDf+WpttvfmSAGSQkFZbwHGlqJ0+EQdQ1W6DqreWfFRGVoh01b5yGdtzYJAzwro3onMn50//X5gAG4ujhPNT2LYUPGBT5+0vPkWXuNd4gWG1yuOcnnv1ChbY+8HAS9T39ABjlAPLxIkJaWdsjFNAjUU1SuDEvMyvYnKKUtUHe64zEQGblK+kFShHieRmR9gSlPlXLZg6EiR17jEnPE08d73r/e4FJZOmZtBPLaJ1Cku3D2Banx7zsJisoZLHMGrmVouTMVmef8BP4AYnPen5dkpnR0ORAciFfSw2Z7hsi5BF+THWjNOouCXFSLR7vF1GF/AfVnluMrLT56frVuov8UcauyBk7C2VcfSqYs4SEySeF3m3jl+jaYHNbj1Ty/JAXspH79dXurRSUt/lEr1zHvGVV7h95zq4qi8PdOfmNWpAu Content-ID: <3F067D2C7894AE4EB7036F65C2866417@eurprd02.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: bitdefender.com X-MS-Exchange-CrossTenant-Network-Message-Id: 19d1a749-9180-48d0-a6e4-08d7944441ff X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jan 2020 14:08:38.3883 (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: tGHJzodaC8c3ZBf3l3IGOPm29/e3QrYivwPO6F9Xd+xPEHs4NzoY4eCgx93MIPR6jpgucLpElDZuyZaCrQNuCR+Iv3I7H8WBGRkP8WX4Eug= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR02MB3253 Subject: [Xen-devel] [PATCH V7 3/4] x86/mm: Pull vendor-independent altp2m code out of p2m-ept.c and into p2m.c 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" No functional changes. Requested-by: Jan Beulich Signed-off-by: Alexandru Isaila Reviewed-by: Jan Beulich Reviewed-by: Kevin Tian --- 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 1c23ea6169..7f9d560df8 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -1359,13 +1359,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 223ca0cf4c..1befc06641 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -2564,6 +2564,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 Wed Jan 8 14:08:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexandru Stefan ISAILA X-Patchwork-Id: 11323751 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 1F9D0109A for ; Wed, 8 Jan 2020 14:09:55 +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 E4D3120643 for ; Wed, 8 Jan 2020 14:09:54 +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="oBHaLWRg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E4D3120643 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 1ipC0r-00044V-E6; Wed, 08 Jan 2020 14:08:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ipC0p-000448-QE for xen-devel@lists.xenproject.org; Wed, 08 Jan 2020 14:08:43 +0000 X-Inumbo-ID: 5fbb204a-3220-11ea-b263-bc764e2007e4 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (unknown [2a01:111:f400:fe0e::70f]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5fbb204a-3220-11ea-b263-bc764e2007e4; Wed, 08 Jan 2020 14:08:42 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F/dLoEI1H9kw12uUxpPs8NjgZkiT1ORWjCorB1yv7RUbSV/rm5XjjKLDWTGViVn4XIVoK4DF7wMwh+d/rDPpg1bZTA2NYTJgeH8QjLF7duXXNo87OIcvyMiSvGszwENSCK7ufm2geQ54HN8lXhmDv2nrFQMJYZCbH0kSPLydM7HCPRonDMiGq0Xv1xnege6ta4Wnj8YdoDnZNwThRo6DSQmvXkPyveleNOP4gTAPWzktpb/sPiLU34Ybh8DgHH+MxqD0CQmyHBaKKrslRLowNt0URLyBCOFab8o0Tu3xU28v2QRl7ZRnA6PcnhPIA/5Q0TwVHOpM76c3ir4a+1PSBQ== 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=oGNuhrvurWoaoWYM0jf/7faysHDX/jCqweoouZB+5b8=; b=VzzeeThDN5cAxiJjHRAHt8aZVWIt8hqjaagKs2S+jEXvALSEBa2f9HiYRDD/6Vkj6irTw30aE0pNbVBuin1OOfXEj+aY1NmssDeYlvDurvBEaH19OCHdCjpQaX1KDcEG5yKICx1D2YyUWybBaZbMoKepMPmt2DwCqgqKWABZUgHfhAKEiXOeHt6IvZq7coCqor2DXnMtBpJRGpywgGnX7+DZcH/zfZFMjNha52QTSCbCWmO3Vql1bnRHNH1LRtfPiBninFTAlxQQOlfXlrVMhKZ75WkzoEprZiu3BDVOr2zTEWA/DBWloUFgojYH87heFSo0X1bpNhcpxiLEUY2m5Q== 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=oGNuhrvurWoaoWYM0jf/7faysHDX/jCqweoouZB+5b8=; b=oBHaLWRgYVjebWYePP22KXtOeyJgTgqA8CAeQCHmuFdbPMgGkyjU9ARlrr8vw1kAaiIVXvWXxFOoaEFZRM1QBBJY0RhC8yy3PYNlxDmY24BfDDlScd9OAA/qkhEhwUoGHwTvb719oyAUsqyUjcT230FvqLMP4M/eIFfGpOvakGQ= Received: from DB6PR02MB2999.eurprd02.prod.outlook.com (10.170.219.144) by DB6PR02MB3253.eurprd02.prod.outlook.com (10.170.221.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.12; Wed, 8 Jan 2020 14:08:40 +0000 Received: from DB6PR02MB2999.eurprd02.prod.outlook.com ([fe80::f1c2:7dd1:1131:1c1d]) by DB6PR02MB2999.eurprd02.prod.outlook.com ([fe80::f1c2:7dd1:1131:1c1d%7]) with mapi id 15.20.2623.008; Wed, 8 Jan 2020 14:08:40 +0000 Received: from aisaila-Latitude-E5570.dsd.bitdefender.biz (91.199.104.6) by AM4PR05CA0023.eurprd05.prod.outlook.com (2603:10a6:205::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2623.9 via Frontend Transport; Wed, 8 Jan 2020 14:08:39 +0000 From: Alexandru Stefan ISAILA To: "xen-devel@lists.xenproject.org" Thread-Topic: [PATCH V7 4/4] x86/mm: Make use of the default access param from xc_altp2m_create_view Thread-Index: AQHVxi0gFxroK8LpSk+v1dIJ+NKYIw== Date: Wed, 8 Jan 2020 14:08:40 +0000 Message-ID: <20200108140810.6528-4-aisaila@bitdefender.com> References: <20200108140810.6528-1-aisaila@bitdefender.com> In-Reply-To: <20200108140810.6528-1-aisaila@bitdefender.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM4PR05CA0023.eurprd05.prod.outlook.com (2603:10a6:205::36) To DB6PR02MB2999.eurprd02.prod.outlook.com (2603:10a6:6:17::16) 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: ef3de219-2fae-46f7-f222-08d794444342 x-ms-traffictypediagnostic: DB6PR02MB3253:|DB6PR02MB3253: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2958; x-forefront-prvs: 02760F0D1C x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(396003)(376002)(346002)(366004)(39850400004)(189003)(199004)(66446008)(16526019)(4326008)(66556008)(54906003)(8676002)(81156014)(66476007)(316002)(64756008)(81166006)(2906002)(6506007)(6512007)(7416002)(6916009)(52116002)(26005)(186003)(66946007)(5660300002)(6666004)(8936002)(36756003)(1076003)(956004)(2616005)(86362001)(478600001)(6486002)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR02MB3253; H:DB6PR02MB2999.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: 3iB7U+wU+eHnqK+swnV00/cIpcvgnGeH9oHfuxr5Edw8AaThOrwDW19wo2dGicd6er2UpIE5QpzhuR+GS2u4ABtx0lZYuubN+HJ/siirEM7CwsF4iIHq8iM6S4Wk92Tm7dCyh88xnkAgI34QdRLzgaWReuOa4y0GuR4svE3cchI+W1E0c+EIto1PFl/Nr1UWbhCqwnJPwk6K9GD3h2bzTrleqCsz2YY8eDv6D8Fgjjz4cVfq23c0Sx5vZZ3M8Sfc2YgnbTX+isSOt+e2V24XJXg/S89pzDV7TrvPM1jtoWzJoHfmxM22Cw6pIQHkDdCURynQvMRXUlMT9e8IZ8dTMd6bsm/Ur+7Ka/Ja4n49y9JdYhoVgcGS5Y9ZocethHtxabwdHGaCwKneLsVkCpxOb8bmL4xBzFn2bt/iA47IuHsv4/0yQDHbUgpc3MmyVyeh Content-ID: MIME-Version: 1.0 X-OriginatorOrg: bitdefender.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef3de219-2fae-46f7-f222-08d794444342 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jan 2020 14:08:40.5071 (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: /ijb8woFxWsudrthRbwN7O7h7bWPZ5Oj/ujXNfZeRVJn0SQQsVuv7Oj265bu8hQXE3HycfWmE2nDLhNkxqre0cIOCMxdI7AYiU02Ccdu41E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR02MB3253 Subject: [Xen-devel] [PATCH V7 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 Acked-by: Jan Beulich --- 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 V6: - Remove the NULL check for p2m in xenmem_access_to_p2m_access() - Use hostp2m for default access in p2m_init_next_altp2m() - Remove the artifact line from p2m_init_next_altp2m(). --- xen/arch/x86/hvm/hvm.c | 3 ++- xen/arch/x86/mm/mem_access.c | 6 +++--- xen/arch/x86/mm/p2m.c | 20 +++++++++++++++----- 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, 26 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 4d79b4934e..b96fafed65 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4654,7 +4654,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 f323d885b1..4ef6a62c31 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(const 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 1befc06641..a811044d6e 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 @@ -2537,7 +2538,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; @@ -2564,7 +2566,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); @@ -2581,6 +2583,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 >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) ) return rc; @@ -2589,16 +2592,23 @@ int p2m_init_altp2m_by_id(struct domain *d, unsigned int idx) if ( d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] == 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 *hostp2m = p2m_get_hostp2m(d); + + if ( hvmmem_default_access > XENMEM_access_default || + !xenmem_access_to_p2m_access(hostp2m, hvmmem_default_access, &a) ) + return rc; altp2m_list_lock(d); @@ -2607,7 +2617,7 @@ 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); + 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 d344606864..610e020a62 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..5d53fb8ce4 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(const 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.