From patchwork Wed Apr 3 14:29:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Stefan ISAILA X-Patchwork-Id: 10883969 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 975FB1390 for ; Wed, 3 Apr 2019 14:31:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 807EC285A0 for ; Wed, 3 Apr 2019 14:31:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73A5C28885; Wed, 3 Apr 2019 14:31:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0D322285A0 for ; Wed, 3 Apr 2019 14:31:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hBgt1-0003n0-K4; Wed, 03 Apr 2019 14:29:07 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hBgt0-0003mv-9N for xen-devel@lists.xenproject.org; Wed, 03 Apr 2019 14:29:06 +0000 X-Inumbo-ID: d4a76388-561c-11e9-bc90-bc764e045a96 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (unknown [2a01:111:f400:fe1e::724]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id d4a76388-561c-11e9-bc90-bc764e045a96; Wed, 03 Apr 2019 14:29:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bitdefender.onmicrosoft.com; s=selector1-bitdefender-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SX2W/2U8j2eyZ0OJFR4QNMlFPHT20nnxaG/Lx5q2H6U=; b=hEpwWeBV3cPdH44U8pjRqIeiecpadhg4zxBo4WtZIJc0AGo94TytVAFt+4jC92TibSgUxyhVZ60yug5kMAEhd8gaGdCl00HwKT+L0euNBrf74Ahk2xeUB69ORklGL8RDOf7XWt6KL9rvCfmF7yWgl2Obz+cRwu4dTju69wceLfg= Received: from VI1PR0202MB2928.eurprd02.prod.outlook.com (10.171.103.139) by VI1PR0202MB3485.eurprd02.prod.outlook.com (52.134.17.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1750.17; Wed, 3 Apr 2019 14:29:01 +0000 Received: from VI1PR0202MB2928.eurprd02.prod.outlook.com ([fe80::dcda:38be:3bd6:14f1]) by VI1PR0202MB2928.eurprd02.prod.outlook.com ([fe80::dcda:38be:3bd6:14f1%9]) with mapi id 15.20.1750.014; Wed, 3 Apr 2019 14:29:00 +0000 From: Alexandru Stefan ISAILA To: "xen-devel@lists.xenproject.org" Thread-Topic: [PATCH v1] Fix p2m_set_suppress_ve Thread-Index: AQHU6imUrZ5W3bOnfUWQBYZ5hKyycw== Date: Wed, 3 Apr 2019 14:29:00 +0000 Message-ID: <20190403142620.1224-1-aisaila@bitdefender.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6P191CA0034.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:8b::47) To VI1PR0202MB2928.eurprd02.prod.outlook.com (2603:10a6:800:de::11) authentication-results: spf=none (sender IP is ) smtp.mailfrom=aisaila@bitdefender.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [91.199.104.6] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 42ccb4c7-c684-467d-1c2f-08d6b840b6d6 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600139)(711020)(4605104)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:VI1PR0202MB3485; x-ms-traffictypediagnostic: VI1PR0202MB3485:|VI1PR0202MB3485: x-microsoft-antispam-prvs: x-forefront-prvs: 0996D1900D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(376002)(396003)(136003)(346002)(366004)(189003)(199004)(25786009)(6506007)(386003)(6436002)(71190400001)(14454004)(3846002)(105586002)(99286004)(6116002)(102836004)(14444005)(50226002)(68736007)(186003)(53936002)(81156014)(256004)(97736004)(107886003)(6512007)(2906002)(2501003)(5640700003)(2351001)(106356001)(305945005)(66066001)(6486002)(5660300002)(508600001)(54906003)(316002)(8936002)(71200400001)(8676002)(1076003)(486006)(2616005)(52116002)(81166006)(6916009)(36756003)(4326008)(476003)(26005)(7736002)(86362001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0202MB3485; H:VI1PR0202MB2928.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-message-info: KH8FkGOn54aX5Mu97Vz9fP0F8BwmCqW0eNgpO70CCnW7ijiXGfbLF1/AGlbDvpA7IrQgVJprY86Zl4/j6DgbZeqvd4dNiv02TqaOq+p2XU4FTvACQUOr4k1q5TzqQfVp2bWU4NPPPZCVnuZC45NgTDj9l4W6c27OcZL2ExWyn+Ww6UFeS4Z1ilbqGrJ28LjiZXjsfm4sibaR7aBeHv6zMDM4Odp0atzswy+oIVyNENZTltIpRHN8UqniBoy0I+0WMH919ZNwbNrLhFLOR/zfZ9wQkqn+K5MCD5V79JfHSjFRVorBMRdz6IXxBj0P4LX8PrTQ+POxmhEuiwg0S6BZNfw+dsoYVn+mAujSkehPXzlLXZugx9qFi9JkeLACQyRmI+LVLwK/UQGsjHW5IiL2Db2Wh56dOssPU2n214FJ1Qc= MIME-Version: 1.0 X-OriginatorOrg: bitdefender.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42ccb4c7-c684-467d-1c2f-08d6b840b6d6 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Apr 2019 14:29:00.8009 (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-Transport-CrossTenantHeadersStamped: VI1PR0202MB3485 Subject: [Xen-devel] [PATCH v1] Fix p2m_set_suppress_ve 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: "wei.liu2@citrix.com" , "george.dunlap@eu.citrix.com" , "andrew.cooper3@citrix.com" , "jbeulich@suse.com" , Alexandru Stefan ISAILA , "roger.pau@citrix.com" Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP On a new altp2m view the p2m_set_suppress_ve() func will fail with invalid mfn from p2m->get_entry() if the p2m->set_entry() was not called before. This patch solves the problem by getting the mfn from __get_gfn_type_access() and then returning error if the mfn is invalid. Signed-off-by: Alexandru Isaila --- xen/arch/x86/mm/p2m.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index b9bbb8f485..3e6e5ef152 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -3011,8 +3011,16 @@ int p2m_set_suppress_ve(struct domain *d, gfn_t gfn, bool suppress_ve, mfn = p2m->get_entry(p2m, gfn, &t, &a, 0, NULL, NULL); if ( !mfn_valid(mfn) ) { - rc = -ESRCH; - goto out; + unsigned int page_order; + + mfn = __get_gfn_type_access(host_p2m, gfn_x(gfn), &t, &a, + P2M_ALLOC | P2M_UNSHARE, &page_order, 0); + + if ( !mfn_valid(mfn) ) + { + rc = -ESRCH; + goto out; + } } rc = p2m->set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, t, a, suppress_ve);