Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1885115pxv; Fri, 2 Jul 2021 15:08:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxj0lJghVceWAAX0J0Kt3lwNj5GS9L2//A4oWt2JbEbYhIq6Ra8l5mTq8Rtqc87B4Odh4U X-Received: by 2002:a50:ec08:: with SMTP id g8mr1985797edr.98.1625263709947; Fri, 02 Jul 2021 15:08:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625263709; cv=none; d=google.com; s=arc-20160816; b=j2uBnDXOBZjIP4aNRFTQYuRS6UWvs51rdg9hb/UQyqggWf2dK9M1GAQYUmcCbaujO4 4ed182YN82IcrB1zVO7cJ0WbvwDN6N+HJA/esjjjIKiPb1Nx8UXuum3rnRJt4aIbztve +8VaX7LjHRcXQj0JjoPQrkG5nBTv3Yc5JPGJHU6/2FMf/3yAHtSDjMKrXs1BRkmnTWy1 2yU08g+1gNAPXzONZclLK7vcD0zjQGG60AJXVPQXg9vM4dE3AzjIg5t3EqNyaZzMcQl7 06k4QdezY5njzfqyCVEvIri5w+KO0hcjCM5/3F6G4hXhwYfpa0DzoTLFkqyF7pWhbxdT nSXA== 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; bh=SN7Lb8k7nfllhYXF8E5xBacJFuxaM7X6LV4avXbfDaU=; b=fjGNYzL3E/pFI19lyceoEB2TMU2W5GsvgRYXhYdBUcW+hMVFP2MOlIjUinUnXvV5ZS FUR/AbfneZjUcAuk8V8AqhyCHNc48L+tUEr8QjtsSOMe3IFZ3HW1uzsry+a34giLjMj9 FG/JTTUt31lwN24BWt8xQ3i0TiGAWvZM1PU0V09wG+7+8/+m3qpRFwprIkcM4zadflL1 2dp+0VDoNm7PtzP7uBQegakotC0qTFzgW2RnULdxfllitAizKHahVFAxfYT3PFQxQ8F3 6prs4scGV5WNUtnE+aR4l9rVGyKYZdh1wqJsI+42yofpLBc/MgRixKfpRBNnDWwm4L6I sbsg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v3si3897312edy.360.2021.07.02.15.08.07; Fri, 02 Jul 2021 15:08:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233542AbhGBWIx (ORCPT + 99 others); Fri, 2 Jul 2021 18:08:53 -0400 Received: from mga12.intel.com ([192.55.52.136]:50200 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233221AbhGBWIA (ORCPT ); Fri, 2 Jul 2021 18:08:00 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10033"; a="188472757" X-IronPort-AV: E=Sophos;i="5.83,320,1616482800"; d="scan'208";a="188472757" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2021 15:05:27 -0700 X-IronPort-AV: E=Sophos;i="5.83,320,1616482800"; d="scan'208";a="642814821" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2021 15:05:27 -0700 From: isaku.yamahata@intel.com To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , erdemaktas@google.com, Connor Kuehl , Sean Christopherson , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Sean Christopherson Subject: [RFC PATCH v2 44/69] KVM: x86/mmu: Refactor shadow walk in __direct_map() to reduce indentation Date: Fri, 2 Jul 2021 15:04:50 -0700 Message-Id: <702419686d5700373123f6ea84e7a946c2cad8b4.1625186503.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson Employ a 'continue' to reduce the indentation for linking a new shadow page during __direct_map() in preparation for linking private pages. Signed-off-by: Sean Christopherson Signed-off-by: Isaku Yamahata --- arch/x86/kvm/mmu/mmu.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 1c40dfd05979..0259781cee6a 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -2910,16 +2910,15 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, break; drop_large_spte(vcpu, it.sptep); - if (!is_shadow_present_pte(*it.sptep)) { - sp = __kvm_mmu_get_page(vcpu, base_gfn, - gfn_stolen_bits, it.addr, - it.level - 1, true, ACC_ALL); - - link_shadow_page(vcpu, it.sptep, sp); - if (is_tdp && huge_page_disallowed && - req_level >= it.level) - account_huge_nx_page(vcpu->kvm, sp); - } + if (is_shadow_present_pte(*it.sptep)) + continue; + + sp = __kvm_mmu_get_page(vcpu, base_gfn, gfn_stolen_bits, + it.addr, it.level - 1, true, ACC_ALL); + + link_shadow_page(vcpu, it.sptep, sp); + if (is_tdp && huge_page_disallowed && req_level >= it.level) + account_huge_nx_page(vcpu->kvm, sp); } ret = mmu_set_spte(vcpu, it.sptep, ACC_ALL, -- 2.25.1