Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4104007rwb; Sun, 7 Aug 2022 15:07:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR4M/Zaey0F2Nf3z8kKiVLl6YhUbt48RZ9Sx79rRnLdCww9hBNiiHudDH3IYU3SkAEKi6Mm2 X-Received: by 2002:a05:6402:438d:b0:43d:b383:660f with SMTP id o13-20020a056402438d00b0043db383660fmr15796492edc.283.1659910073164; Sun, 07 Aug 2022 15:07:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659910073; cv=none; d=google.com; s=arc-20160816; b=OU7KMPAoyQJujnQeh6SAcbhvZVbbNEU7MABHWz1b7MxBfcKpFtiNOqF1Vk/D2m6AqG lrZ2QpRcIYBLkLFqSVj84Enm/0oIMmyReusSn4CmAWPzUq4tM5UkUQm1Fb96qVpwDAmQ fou4ir1yFAlFCPr2sIc7T0jMpRVmcsY7FJ08H52iQC1hc5aBmm6NSB40XJtDYuq2Z9q3 bFEBRylN1fYjj3681XJfO4rLh6fNv/pnr7o6CnGQOgjLORKKFiqf++FoB87V/KUTZNYH UG0tuxqXnbiF7Y9APVg0pUGaNvg92T6NiKHB076v9JDDpIk0TTa5XNXX+OKH8jcLwRac 9AsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=27rHW8jWxnGEHkFTyJaOGBtvIdOqiM2xqQeRq5g+l3Q=; b=NZ/TKL1yGb6cAeKt8ZPZSHPtpCLQjeuM7rb5Y7IWC9w9DD3mDnVop+sdx8wcYFwFov zEgXblagOR2moQ31o5PBkTkihdDucjmC4x7GBt8GLQekROHXvjPX2XX8LgeJ55YBdr9Z UtvlUQxv0kHRZBSqE6+Be3dm3gW5Cb6BboMkdT6+T/Di2TzKLDZ1kbse7nGfy7zWIF6p YbbtDRbl09hOOb+8mBYZ2QXSr1OySeOMCcOWS8f6upeX+pvypzG8/Cso2BNMLdoMMETC Jzj9jfL0E0SjaaTnt5nAR8Pr/TTXvbVY7XxSZ942CR19/ItESYJ3NQWL0q5v3jlRFMx0 6qWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Dqscltnq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j27-20020a056402239b00b0043e1358f449si4784663eda.621.2022.08.07.15.07.27; Sun, 07 Aug 2022 15:07:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Dqscltnq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237452AbiHGWFk (ORCPT + 99 others); Sun, 7 Aug 2022 18:05:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234424AbiHGWCu (ORCPT ); Sun, 7 Aug 2022 18:02:50 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A930659C; Sun, 7 Aug 2022 15:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659909759; x=1691445759; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=paWoV8vUP0AomUkaEVAHF3tFMPkBIX0/rPM1U6g0wYs=; b=DqscltnqfqDn91TBWFBJAyHCH591tkw4q7wItC6cMAix5g/AY6eM9rQt Nbj93HUK8TWtz7Zm8J6TVBcZZYA14ifGHmOlw6Bi2WEO6nUxDf0THBv89 bPc7jI+IxxyJuPxe2PZYabDvrZB47WzHsAoVGa5+b6UaUHZ7HebWZcuNW dd4KInyf/XU91TrpqX4DnhJZeXD7+ftKcM7WXQn4E7NJcUOIfDbH71Svs Yo5IJdwMb+6xoB7vdxa93wEFpnJJhP8hP/3LJi5yoU/4Ff4CrJFfXtC88 hiRi34y3VVZIVfHc71rTDGiYu0K5PLKJ1r+HNuwUgaVlw6eUQNNlrCT3W A==; X-IronPort-AV: E=McAfee;i="6400,9594,10432"; a="354465750" X-IronPort-AV: E=Sophos;i="5.93,220,1654585200"; d="scan'208";a="354465750" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2022 15:02:38 -0700 X-IronPort-AV: E=Sophos;i="5.93,220,1654585200"; d="scan'208";a="663682628" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2022 15:02:37 -0700 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar Subject: [PATCH v8 056/103] KVM: x86/mmu: Let vcpu re-try when faulting page type conflict Date: Sun, 7 Aug 2022 15:01:41 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaoyao Li When it gets a private page fault on a shared page, or vice verse, let vcpu retry and vcpu will keep faulting until other vcpu maps the gpa to matched page type. Signed-off-by: Xiaoyao Li Signed-off-by: Isaku Yamahata --- arch/x86/kvm/mmu/mmu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 27deaf44ee80..c9c27945ed44 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -4230,6 +4230,10 @@ static int kvm_faultin_pfn(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault) return RET_PF_EMULATE; } + if (kvm_gfn_shared_mask(vcpu->kvm) && + (kvm_mem_is_private(vcpu->kvm, fault->gfn) != fault->is_private)) + return RET_PF_RETRY; + async = false; fault->pfn = __gfn_to_pfn_memslot(slot, fault->gfn, false, &async, fault->write, &fault->map_writable, -- 2.25.1