From patchwork Wed Sep 4 14:20:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 11130883 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 9CBAD1395 for ; Wed, 4 Sep 2019 14:22:25 +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 7882A22CED for ; Wed, 4 Sep 2019 14:22:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="QvrH0Wqc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7882A22CED Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=citrix.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 1i5W9C-0000VH-Dj; Wed, 04 Sep 2019 14:20:34 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i5W9B-0000VC-7z for xen-devel@lists.xenproject.org; Wed, 04 Sep 2019 14:20:33 +0000 X-Inumbo-ID: 2723befe-cf1f-11e9-a337-bc764e2007e4 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2723befe-cf1f-11e9-a337-bc764e2007e4; Wed, 04 Sep 2019 14:20:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1567606832; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ZYX6wYx4qjiZh95p+nP0xj1a/b2Xi2vHwwmYJ0nSRQM=; b=QvrH0Wqc47p9LauGtFEa6POt0tDtnOYeTCfj22vSiwZznrIJxuHNrOK9 BswAIuDkhcXJOVeD3B3Uv7T+rj68b8FU5B7XRxrWrtryRLdunip19e0Y9 l8IypwX5H7gXfkSatvEyL+5TixdMFddVyuXJf4SNmhsO//hG6MLhdzlAg k=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=roger.pau@citrix.com; spf=Pass smtp.mailfrom=roger.pau@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of roger.pau@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of roger.pau@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: DLwzWs2bUOUrmz+ynIBA2ytAyJN8gCbOZtLFRg+9YefDezheUMUNgQ/I99ERjQiPlHREvR91fs RMIhRPV/10efT2OQJwBiEW31cOtZ4DmpA3vx8pTE2CKntivsujuTicjxikV7lkPRZ1+Vpn3++d f3RnLqE5OEwVk6hU1jwdxOSXNaGFEoORUwHsXquNuHhW/+XpfZbdq33KkBOAjC0aWiwVFswA5b rl2Wxwm+6e9tTE/2sUN/7E+rVe1FObF8Nvjod90lVGQMw+E9+ove7KTVfMTfWgkyuk4j99OOBX d60= X-SBRS: 2.7 X-MesageID: 5392662 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,467,1559534400"; d="scan'208";a="5392662" From: Roger Pau Monne To: Date: Wed, 4 Sep 2019 16:20:26 +0200 Message-ID: <20190904142026.9946-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] p2m/ept: add _subtree suffix to ept_invalidate_emt 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 , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" So that the name implies the function is used to walk the page table pointer passed as parameter. Drop the parent_ prefix from the level parameter, since the level passed is the one matching the EPT entry passed in the mfn parameter. While there also change bool_t to bool and add an assert to make sure no level 0 entries (ie: 4K EPT leaf entries) are passed as parameters. No functional change intended. Suggested-by: Kevin Tian Signed-off-by: Roger Pau Monné Reviewed-by: Kevin Tian --- xen/arch/x86/mm/p2m-ept.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index 952ebad82f..d0e62905f8 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -348,13 +348,19 @@ static int ept_next_level(struct p2m_domain *p2m, bool_t read_only, * present entries in the given page table, optionally marking the entries * also for their subtrees needing P2M type re-calculation. */ -static bool_t ept_invalidate_emt(struct p2m_domain *p2m, mfn_t mfn, - bool_t recalc, unsigned int parent_level) +static bool ept_invalidate_emt_subtree(struct p2m_domain *p2m, mfn_t mfn, + bool recalc, unsigned int level) { int rc; ept_entry_t *epte = map_domain_page(mfn); unsigned int i; - bool_t changed = 0; + bool changed = false; + + if ( !level ) + { + ASSERT_UNREACHABLE(); + return false; + } for ( i = 0; i < EPT_PAGETABLE_ENTRIES; i++ ) { @@ -367,9 +373,9 @@ static bool_t ept_invalidate_emt(struct p2m_domain *p2m, mfn_t mfn, e.emt = MTRR_NUM_TYPES; if ( recalc ) e.recalc = 1; - rc = atomic_write_ept_entry(p2m, &epte[i], e, parent_level - 1); + rc = atomic_write_ept_entry(p2m, &epte[i], e, level - 1); ASSERT(rc == 0); - changed = 1; + changed = true; } unmap_domain_page(epte); @@ -378,7 +384,7 @@ static bool_t ept_invalidate_emt(struct p2m_domain *p2m, mfn_t mfn, } /* - * Just like ept_invalidate_emt() except that + * Just like ept_invalidate_emt_subtree() except that * - not all entries at the targeted level may need processing, * - the re-calculation flag gets always set. * The passed in range is guaranteed to not cross a page (table) @@ -574,7 +580,7 @@ static int resolve_misconfig(struct p2m_domain *p2m, unsigned long gfn) if ( e.emt == MTRR_NUM_TYPES ) { ASSERT(is_epte_present(&e)); - ept_invalidate_emt(p2m, _mfn(e.mfn), e.recalc, level); + ept_invalidate_emt_subtree(p2m, _mfn(e.mfn), e.recalc, level); smp_wmb(); e.emt = 0; e.recalc = 0; @@ -1006,7 +1012,7 @@ static void ept_change_entry_type_global(struct p2m_domain *p2m, if ( !mfn ) return; - if ( ept_invalidate_emt(p2m, _mfn(mfn), 1, p2m->ept.wl) ) + if ( ept_invalidate_emt_subtree(p2m, _mfn(mfn), 1, p2m->ept.wl) ) ept_sync_domain(p2m); } @@ -1064,7 +1070,7 @@ static void ept_memory_type_changed(struct p2m_domain *p2m) if ( !mfn ) return; - if ( ept_invalidate_emt(p2m, _mfn(mfn), 0, p2m->ept.wl) ) + if ( ept_invalidate_emt_subtree(p2m, _mfn(mfn), 0, p2m->ept.wl) ) ept_sync_domain(p2m); }