Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp109156iof; Sun, 5 Jun 2022 22:39:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnYKGA2Ch7yQdjrQH6Y7cD9RBBnj9c1OHZYvRvIHMlmJB734ZWENeGecZOQGavN0i11rsL X-Received: by 2002:a17:90a:7381:b0:1e2:ff0f:df07 with SMTP id j1-20020a17090a738100b001e2ff0fdf07mr24967906pjg.160.1654493992223; Sun, 05 Jun 2022 22:39:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654493992; cv=none; d=google.com; s=arc-20160816; b=UW32fkXtSVvKlcXpJJxEJyKirALWsDt0H1tQI+30cAGiO/N0FzUFrbuXzxi8TUx1iU PRiS1iAD1t6lgI2d9w20y0Elslv9vJ9bABIvbwlB4LFne6Ne+1eP+UfFOa4Z/+D9aT7P uj49foEJN3o3YV9CaxtN0erKWdNsi/Q9wiHn+5Veid/5yPxUsg4NYZBvkBtfk37EobJ5 3ZXtkaT1i16h1J7EouT+FUR3Idwartv8G+CudTrZ+rXIpXjD+b6GQgMYil7neGHVDDHd nmbwDagUwueFJqCi9dLWZ0qrlTSNrW3iBuv/Le4LLP/eTmR0wlNr2f/h547Q9AnqbNsa a5KQ== 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=9ZPEYVPT8lSmzrFfSReWUpWaXzCkp32kYLA9BRd9poo=; b=rVhqHNffxtyy1pd3tmch5rEemhd+D7RXbd9Ktfikcq5pYWjQYTFIBK6UsI94zWmC26 dcghTrmvp5xiaFUkbiSoRAcpqbYHwobodtVdNMAgliPuKhUyGyHGFNvc66TOAUb0QBI6 aFmocJVerOyn5Hm4IXHDICVardRggJrLdKB5jN3jivN2RQjiAChLeqsUm8boN8Dyp9ST 5GMdi8BtROotLO9y2ww7ZkldyRg/OOnYD8VDapRvu4e3rkSo/djoIkTlPHKBi9NmFVcL 0z0+ljqJ3oXUkN5sT9F2SWqkdT5QQW3dpTFOu/+FIh8691C16R9AmaRon36Nt+AR+Fmr fEQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZNn0WASD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j14-20020a056a00130e00b005182883ce81si21974189pfu.155.2022.06.05.22.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 22:39:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZNn0WASD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 30AA21B7AE; Sun, 5 Jun 2022 21:45:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350814AbiFEGoO (ORCPT + 99 others); Sun, 5 Jun 2022 02:44:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350825AbiFEGn7 (ORCPT ); Sun, 5 Jun 2022 02:43:59 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 683DE483AF; Sat, 4 Jun 2022 23:43:28 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id n8so9866005plh.1; Sat, 04 Jun 2022 23:43:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9ZPEYVPT8lSmzrFfSReWUpWaXzCkp32kYLA9BRd9poo=; b=ZNn0WASDiHjxRFywP5TR73R8wJiC3ZSdxxKyspy9RLQdrkXYFta3MBrcxf84vmim5j c7nJdyx85YRp8jUZtcteGz6fD50M36c5Ew2w92iQNUcmZYxVQpDEHSJrUQpMaK82xbBh W+hVKL0c6cZlEAk5NNfLEgoGU17jUZpJDgCDvq71EMHFkyGbCPy5LJ6//gTetBajJuqp 4QqIqKQVAHPWWcXNgAgx91QaVoI19hKygJCUL5E2j1f1NhNcUzbU/eviuqaPJBEL23i+ 3h+Fw42rkQcH56WMnHbdDMyh6IK0lSYJmBnsKfNTfj9IPdzRyFA358b7SKt/ZNzoixO0 69Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9ZPEYVPT8lSmzrFfSReWUpWaXzCkp32kYLA9BRd9poo=; b=16RKKU+NALGwjRymfBld11/H8mHWMg9Uxoz4YGJjq2HEpvzdtjv/RBhr2N7ZBN8YK1 nTKLU0DfNJz3pNYwc/8193zzJdUsr6V1T1KtjtXO2caODJ+oeV7LvJ+k4y/blIxzRax6 eqF8KfJItlt5KUkdHoX5qcM7GEmIVOINpTse5kllJ5EyCirHXuCfrQnPoq/gMDZWhlCN vQLSz5L3uwUt0KI87RNDRtPPHWAYKqb09KJ2EA/o/tnh4wcjrYpVUcTlT86xACIEDUtf kemeGVa1ncFeZmPUh7yOWNddiBo8udCFh9JZs5Y2qOMNqWiAHV+8k8ArsxLm38K44eSd b6wQ== X-Gm-Message-State: AOAM530b39jOa1cNdRlIyxJvN6GZ0Kbp6gbKgD7+sZcV0o+c1/K1Xjba bg+3nshPgPEWm4JcLGcMRVaPX2XqYIE= X-Received: by 2002:a17:90b:4a92:b0:1e8:2ba1:64bf with SMTP id lp18-20020a17090b4a9200b001e82ba164bfmr12833283pjb.41.1654411407330; Sat, 04 Jun 2022 23:43:27 -0700 (PDT) Received: from localhost ([198.11.178.15]) by smtp.gmail.com with ESMTPSA id js24-20020a17090b149800b001df3a251cc2sm10376609pjb.4.2022.06.04.23.43.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 Jun 2022 23:43:27 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Maxim Levitsky , Lai Jiangshan Subject: [PATCH 09/12] KVM: X86/MMU: Unfold struct mmu_page_and_offset in struct kvm_mmu_pages Date: Sun, 5 Jun 2022 14:43:39 +0800 Message-Id: <20220605064342.309219-10-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20220605064342.309219-1-jiangshanlai@gmail.com> References: <20220605064342.309219-1-jiangshanlai@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: Lai Jiangshan struct kvm_mmu_page *sp is the only field in struct mmu_page_and_offset. Unfold it. Signed-off-by: Lai Jiangshan --- arch/x86/kvm/mmu/mmu.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index dc159db46b34..a5563e5ee2e5 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -1743,9 +1743,7 @@ static int nonpaging_sync_page(struct kvm_vcpu *vcpu, #define KVM_PAGE_ARRAY_NR 16 struct kvm_mmu_pages { - struct mmu_page_and_offset { - struct kvm_mmu_page *sp; - } page[KVM_PAGE_ARRAY_NR]; + struct kvm_mmu_page *sp[KVM_PAGE_ARRAY_NR]; unsigned int nr; }; @@ -1755,10 +1753,10 @@ static int mmu_pages_add(struct kvm_mmu_pages *pvec, struct kvm_mmu_page *sp) if (sp->unsync) for (i=0; i < pvec->nr; i++) - if (pvec->page[i].sp == sp) + if (pvec->sp[i] == sp) return 0; - pvec->page[pvec->nr].sp = sp; + pvec->sp[pvec->nr] = sp; pvec->nr++; return (pvec->nr == KVM_PAGE_ARRAY_NR); } @@ -1894,7 +1892,7 @@ static bool is_obsolete_sp(struct kvm *kvm, struct kvm_mmu_page *sp) #define for_each_sp(pvec, sp, i) \ for (i = mmu_pages_first(&pvec); \ - i < pvec.nr && ({ sp = pvec.page[i].sp; 1;}); \ + i < pvec.nr && ({ sp = pvec.sp[i]; 1;}); \ i = mmu_pages_next(&pvec, i)) static int mmu_pages_next(struct kvm_mmu_pages *pvec, int i) @@ -1902,7 +1900,7 @@ static int mmu_pages_next(struct kvm_mmu_pages *pvec, int i) int n; for (n = i+1; n < pvec->nr; n++) { - struct kvm_mmu_page *sp = pvec->page[n].sp; + struct kvm_mmu_page *sp = pvec->sp[n]; int level = sp->role.level; if (level == PG_LEVEL_4K) @@ -1921,7 +1919,7 @@ static int mmu_pages_first(struct kvm_mmu_pages *pvec) if (pvec->nr == 0) return 0; - sp = pvec->page[0].sp; + sp = pvec->sp[0]; level = sp->role.level; WARN_ON(level == PG_LEVEL_4K); -- 2.19.1.6.gb485710b