Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2912863imm; Mon, 13 Aug 2018 02:43:28 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxGBIHCXLnY4kGZmz4g3XMPfUB/FuHBnFYjpQL1fICiElB/VcPycuvsk5ip0cGUZiix3PIU X-Received: by 2002:a62:3856:: with SMTP id f83-v6mr18404762pfa.48.1534153407952; Mon, 13 Aug 2018 02:43:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534153407; cv=none; d=google.com; s=arc-20160816; b=iaCBL07KsL3j90972rOnaZfzjk4eF+Xo7ckdIK2AKoCIuFY/QH2XE0I9jQmiSMxxrO oSTCrgo+ZR3luzd0hOXCUjYBfcbZuLJBLxEggdNCDZoa78jkVjysucpqIj5fJo3wLBOX OS8OngFzUVB/XwXsluJkzEZQmv5ICS4JWExvYwfOPym3bFh+Wa5J9H9sl34MU8yE1bBg KuBYOxx57yOeo57BlCLwUy0T8gukyrJZgLY71k/d6u8BI65BWYyzVaKz0qm5l3LeXUTn ysyJG9CXlJSEQ5y29hDGRtFbgqkguz2FwCBOfNNVPLQ46gPB0TWjP2AQv3LLVXDPf5hU TMSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=dwnpcGnPAoneTKY4rWgHjR3465HdLm0U53SlOYcl9OU=; b=vzOZoRmF6c0oyh0xRN0UBljOllFctVZy14I8yFnWFdJ+EYrh3qglUDgE67eO2A+qnP ERxpE7ajNbuJZGt51tlpli2yM/73fizMaJde3tX9ALqidefbXpgKaCj+6Xe9VnLjWCTF VCPwUDY1ohkFWmBzGI4wvulI1V2GqFCDCwCzAi5OQh13O63lysvtJPBOLfHygGceuNMI x/GxmiaQNmxEJjeqTTZ1IXFbXed0nFTYj8zspxa0eNOvAAQrW1XVV8Rj7Ta5fBaTCV2S Hcgp5tI9GE/wBxLuo4hLvHKuWSpt2nCO2+jLTdee+GitRr2wDFxR+zwZuqzQPbZGu1Td +DZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u26-v6si14359482pge.590.2018.08.13.02.43.12; Mon, 13 Aug 2018 02:43:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729056AbeHMMWy (ORCPT + 99 others); Mon, 13 Aug 2018 08:22:54 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:56054 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728313AbeHMMWy (ORCPT ); Mon, 13 Aug 2018 08:22:54 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 808857A9; Mon, 13 Aug 2018 02:41:26 -0700 (PDT) Received: from localhost (e105922-lin.emea.arm.com [10.4.13.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 258373F73C; Mon, 13 Aug 2018 02:41:26 -0700 (PDT) From: Punit Agrawal To: kvmarm@lists.cs.columbia.edu Cc: Punit Agrawal , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, suzuki.poulose@arm.com, marc.zyngier@arm.com, christoffer.dall@arm.com, stable@vger.kernel.org Subject: [PATCH v2 2/2] KVM: arm/arm64: Skip updating PTE entry if no change Date: Mon, 13 Aug 2018 10:40:49 +0100 Message-Id: <20180813094049.3726-3-punit.agrawal@arm.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180813094049.3726-1-punit.agrawal@arm.com> References: <20180813094049.3726-1-punit.agrawal@arm.com> X-ARM-No-Footer: FoSSMail Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When there is contention on faulting in a particular page table entry at stage 2, the break-before-make requirement of the architecture can lead to additional refaulting due to TLB invalidation. Avoid this by skipping a page table update if the new value of the PTE matches the previous value. Fixes: d5d8184d35c9 ("KVM: ARM: Memory virtualization setup") Change-Id: I28e17daf394a4821b13c2cf8726bf72bf30434f9 Signed-off-by: Punit Agrawal Cc: Marc Zyngier Cc: Christoffer Dall Cc: Suzuki Poulose Cc: stable@vger.kernel.org --- virt/kvm/arm/mmu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index 2ab977edc63c..d0a9dccc3793 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -1120,6 +1120,10 @@ static int stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache, /* Create 2nd stage page table mapping - Level 3 */ old_pte = *pte; if (pte_present(old_pte)) { + /* Skip page table update if there is no change */ + if (pte_val(old_pte) == pte_val(*new_pte)) + goto out; + kvm_set_pte(pte, __pte(0)); kvm_tlb_flush_vmid_ipa(kvm, addr); } else { @@ -1127,6 +1131,7 @@ static int stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache, } kvm_set_pte(pte, *new_pte); +out: return 0; } -- 2.18.0