From patchwork Thu Sep 26 09:46:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11162175 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 E941213BD for ; Thu, 26 Sep 2019 09:51:09 +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 C542B2053B for ; Thu, 26 Sep 2019 09:51:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="vASdipTh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C542B2053B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.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 1iDQPl-0008K5-54; Thu, 26 Sep 2019 09:50:21 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iDQPi-00087i-RO for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:50:18 +0000 X-Inumbo-ID: 07ae05f4-e043-11e9-8628-bc764e2007e4 Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by localhost (Halon) with ESMTPS id 07ae05f4-e043-11e9-8628-bc764e2007e4; Thu, 26 Sep 2019 09:50:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491411; x=1601027411; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=8z0oYlQF1Bg6k3+OWJ/LtkFIqff1rqs7pLf37Fuu1Ss=; b=vASdipThD4YWNSFvq4Ra9zVfSFI8d9kXB/Fl/E/ZFYn9nUJbXDKDTPmw Kp9RftGRIlx8PdEpwk6DIqE8XvJ5OxuyZCasFNwfaD+YjV59WhoqY/9Dn xwX2wJn2eKF2FoJx2O27GLLO3bHGmztjrAjh/qTc91OpnuDxgTxEoWtB3 s=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="704637411" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1a-af6a10df.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 26 Sep 2019 09:49:04 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1a-af6a10df.us-east-1.amazon.com (Postfix) with ESMTPS id 9E60EA2616; Thu, 26 Sep 2019 09:48:48 +0000 (UTC) Received: from EX13D28EUB004.ant.amazon.com (10.43.166.176) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:48 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUB004.ant.amazon.com (10.43.166.176) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:48:46 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:48:44 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:22 +0100 Message-ID: <3dba7fe6e3a9be5f41d02d41bc4ec6dbb1ba734c.1569489002.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [RFC PATCH 59/84] x86/pmap: break the loop in pmap APIs. X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , Wei Liu , Jan Beulich , Hongyan Xia Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Modify the pmap PTEs directly. Using set/clear_fixmap() may result in invocation loops. Signed-off-by: Hongyan Xia --- xen/arch/x86/pmap.c | 11 ++++++++--- xen/include/asm-x86/pmap.h | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/pmap.c b/xen/arch/x86/pmap.c index 4ae16b0212..93104d0b86 100644 --- a/xen/arch/x86/pmap.c +++ b/xen/arch/x86/pmap.c @@ -29,11 +29,12 @@ void pmap_unlock(void) spin_unlock(&lock); } -void *pmap_map(struct page_info *page) +void *pmap_map(mfn_t mfn) { unsigned int idx; void *linear = NULL; enum fixed_addresses slot; + l1_pgentry_t *pl1e; ASSERT(!in_irq()); ASSERT(spin_is_locked(&lock)); @@ -47,7 +48,8 @@ void *pmap_map(struct page_info *page) slot = idx + FIX_PMAP_BEGIN; ASSERT(slot >= FIX_PMAP_BEGIN && slot <= FIX_PMAP_END); - set_fixmap(slot, mfn_x(page_to_mfn(page))); + pl1e = &l1_fixmap[L1_PAGETABLE_ENTRIES - 1 - slot]; + l1e_write_atomic(pl1e, l1e_from_mfn(mfn, PAGE_HYPERVISOR)); linear = (void *)__fix_to_virt(slot); return linear; @@ -56,6 +58,7 @@ void *pmap_map(struct page_info *page) void pmap_unmap(void *p) { unsigned int idx; + l1_pgentry_t *pl1e; enum fixed_addresses slot = __virt_to_fix((unsigned long)p); ASSERT(!in_irq()); @@ -64,7 +67,9 @@ void pmap_unmap(void *p) idx = slot - FIX_PMAP_BEGIN; __clear_bit(idx, &inuse); - clear_fixmap(slot); + + pl1e = &l1_fixmap[L1_PAGETABLE_ENTRIES - 1 - slot]; + l1e_write_atomic(pl1e, l1e_from_mfn(_mfn(0), 0)); } static void __maybe_unused build_assertions(void) diff --git a/xen/include/asm-x86/pmap.h b/xen/include/asm-x86/pmap.h index 42cd4c7793..feab1e9170 100644 --- a/xen/include/asm-x86/pmap.h +++ b/xen/include/asm-x86/pmap.h @@ -6,7 +6,7 @@ void pmap_lock(void); void pmap_unlock(void); -void *pmap_map(struct page_info *page); +void *pmap_map(mfn_t mfn); void pmap_unmap(void *p); #endif /* __X86_PMAP_H__ */