From nobody Tue Nov 11 08:31:25 2025 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1569426654; cv=none; d=zoho.com; s=zohoarc; b=NG+y50NsM1gb8ZdZfnjOPygaft4vDw2mI3iwH/2IXn/OukcjxRGG++lLYr6SUJwXRmfaqK6CmdwZMLLspOjF7dsLBdbplrxsCiMgjnJgGUO2+8+Pi8S/6u907aZh7cZzwGJPxkTuMi3MvOKMI8rWdWeVT/Iqy9lu8gmRKZCMFfg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569426654; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=a5VoKi6F5UF2MMphZKRh24TAGxErSYnHDATO1uj9Jo0=; b=YRhtUxF/4WP2Gq/w8I6TBcim4bAmvzR53ZLkMP6hfnNO+dXxcoSUkvXwqBcHVJCqX5Nig1WF8uWMx8v/MRzKVTylWEsvamCnz2LzSUQMCniDZIzUrZM4E6ErPsD0ttNmitPIraySbD7SC40/RULPtyc5Nkgq++677u3ioyjpYSY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1569426654761325.3977551535505; Wed, 25 Sep 2019 08:50:54 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iD9YE-00014a-DL; Wed, 25 Sep 2019 15:49:58 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iD9YC-000139-Nx for xen-devel@lists.xenproject.org; Wed, 25 Sep 2019 15:49:56 +0000 Received: from mga12.intel.com (unknown [192.55.52.136]) by localhost (Halon) with ESMTPS id 11e6bb5c-dfac-11e9-8628-bc764e2007e4; Wed, 25 Sep 2019 15:49:34 +0000 (UTC) Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Sep 2019 08:49:32 -0700 Received: from tlengyel-mobl2.amr.corp.intel.com (HELO localhost.localdomain) ([10.252.129.153]) by orsmga006.jf.intel.com with ESMTP; 25 Sep 2019 08:49:31 -0700 X-Inumbo-ID: 11e6bb5c-dfac-11e9-8628-bc764e2007e4 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,548,1559545200"; d="scan'208";a="193812656" From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Date: Wed, 25 Sep 2019 08:48:45 -0700 Message-Id: <8be4685eb151ec323f822fdee0d55cb2be7ab1b2.1569425745.git.tamas.lengyel@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [RFC PATCH for-next 07/18] x86/mem_sharing: don't try to unshare twice during page fault 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: Andrew Cooper , Tamas K Lengyel , Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The page was already tried to be unshared in get_gfn_type_access. If that didn't work, then trying again is pointless. Don't try to send vm_event aga= in either, simply check if there is a ring or not. Signed-off-by: Tamas K Lengyel --- xen/arch/x86/hvm/hvm.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 7c255728c2..2af2f936a5 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -1701,11 +1702,14 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned= long gla, struct domain *currd =3D curr->domain; struct p2m_domain *p2m, *hostp2m; int rc, fall_through =3D 0, paged =3D 0; - int sharing_enomem =3D 0; vm_event_request_t *req_ptr =3D NULL; bool sync =3D false; unsigned int page_order; =20 +#ifdef CONFIG_MEM_SHARING + bool sharing_enomem =3D false; +#endif + /* On Nested Virtualization, walk the guest page table. * If this succeeds, all is fine. * If this fails, inject a nested page fault into the guest. @@ -1875,14 +1879,16 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned= long gla, if ( p2m_is_paged(p2mt) || (p2mt =3D=3D p2m_ram_paging_out) ) paged =3D 1; =20 - /* Mem sharing: unshare the page and try again */ - if ( npfec.write_access && (p2mt =3D=3D p2m_ram_shared) ) +#ifdef CONFIG_MEM_SHARING + /* Mem sharing: if still shared on write access then its enomem */ + if ( npfec.write_access && p2m_is_shared(p2mt) ) { ASSERT(p2m_is_hostp2m(p2m)); - sharing_enomem =3D mem_sharing_unshare_page(currd, gfn); + sharing_enomem =3D true; rc =3D 1; goto out_put_gfn; } +#endif =20 /* Spurious fault? PoD and log-dirty also take this path. */ if ( p2m_is_ram(p2mt) ) @@ -1936,19 +1942,21 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned= long gla, */ if ( paged ) p2m_mem_paging_populate(currd, gfn); + +#ifdef CONFIG_MEM_SHARING if ( sharing_enomem ) { - int rv; - - if ( (rv =3D mem_sharing_notify_enomem(currd, gfn, true)) < 0 ) + if ( !vm_event_check_ring(currd->vm_event_share) ) { gdprintk(XENLOG_ERR, "Domain %hu attempt to unshare " - "gfn %lx, ENOMEM and no helper (rc %d)\n", - currd->domain_id, gfn, rv); + "gfn %lx, ENOMEM and no helper\n", + currd->domain_id, gfn); /* Crash the domain */ rc =3D 0; } } +#endif + if ( req_ptr ) { if ( monitor_traps(curr, sync, req_ptr) < 0 ) --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel