Message ID | 20231204144334.910-7-paul@xen.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2809135vqy; Mon, 4 Dec 2023 06:44:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IE3TkMkljVatnLwJoUg/jTOMCD7aF4joEPv86PF6w+CIezdGDGlP7hBUaMPJ07GkCrCjnHJ X-Received: by 2002:a05:6a00:2e17:b0:6ce:2732:584 with SMTP id fc23-20020a056a002e1700b006ce27320584mr5055932pfb.53.1701701091908; Mon, 04 Dec 2023 06:44:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701701091; cv=none; d=google.com; s=arc-20160816; b=zTsLsKW+4bzXoG68CQGhZ+jZ6L/OtN78ki7z7j2IMNcZJcg+BmVC5TJdjSSV4ZSZ9l 4qoTJrhSxnY0Ya0ii5otQaZ3RuKLkLRKszMsybty/51pz2CqlLmUl3XHf1UozrVrB51S zq0zgASRVcF/sCTGUPLfgfbdM0SStRXeZcjNMnLw0F8Gy34t4fkcmW9II6z+otSDS8hg cbGRRT1DLrgZ2nTci4mXjaNXF0B42qustW1818g1cEDxFirr7e2Xp4MmgrF0QSvvjsx5 JkDZt5sL/otxT8cC0ok+kJ2E/KfzNSLgXmiSZzvmcYZ2hYUgGZg/hmAkiZl9HO8hq63Y M4dA== 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:to:from :dkim-signature; bh=iyqOFrP3aGKoiCQ7WXZlsE4e+dflFfzsWYBVMlCow44=; fh=aAPqvXm40pY9772UiBOljEePwtz/3Q0zIOpw238tj3M=; b=uMKRjDqgRI3d8oJbNbRAPOURM9JZfuRoCdKRzBLb8zG9PEsVzSNBYBcbpRCvA3EaVi 8RI0Rj7XqwTE2NV8Wf/oBH5E/zi7ng7yt1nkLyG55RZ3WuAg4jcjt8HvEkJ6LP7hpDcm KfwetFDvPbr1M1fpB0K6h9JWmTtpq3EjCc5psv6WoRlRMGK+6YadYT25wAkN7mu9wdDI udv6yW8PJo5CZBbtXHaKfXpPBEncpk3r0sHMkdNzC5s1I2R6M4x9Icy5MO9k22oQMKbQ pe/yS1yUP1/nrlaVj4W01AOFhxeeNzc55EUtb5mDTUqtSvTXM7/URF/oBaya2wOnCtZQ GPJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=RKdWfr20; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id dn12-20020a056a00498c00b006cdcff16880si4081600pfb.356.2023.12.04.06.44.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 06:44:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=RKdWfr20; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0714180A9900; Mon, 4 Dec 2023 06:44:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346082AbjLDOof (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Mon, 4 Dec 2023 09:44:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235931AbjLDOoR (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 4 Dec 2023 09:44:17 -0500 Received: from mail.xenproject.org (mail.xenproject.org [104.130.215.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4ECF3D3; Mon, 4 Dec 2023 06:44:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:To:From; bh=iyqOFrP3aGKoiCQ7WXZlsE4e+dflFfzsWYBVMlCow44=; b=RKdWfr200BFIUema/55xg+FWV4 wMI1fPg4QvaaHQuARZFXsDroQV4YFOs4dNIhRrQnNCSTR874QecJetgrRiYGiUIaoNpN28SskZZZ1 nBVSrAC0g7ea87iX2JHazfVX4oHHNHa3/ggmvypWoDcBc4XGVji65T2v4iqyoJtoY3mI=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from <paul@xen.org>) id 1rAAB6-0003ex-KF; Mon, 04 Dec 2023 14:44:08 +0000 Received: from 54-240-197-231.amazon.com ([54.240.197.231] helo=REM-PW02S00X.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <paul@xen.org>) id 1rAAB6-00088g-AT; Mon, 04 Dec 2023 14:44:08 +0000 From: Paul Durrant <paul@xen.org> To: Paolo Bonzini <pbonzini@redhat.com>, Jonathan Corbet <corbet@lwn.net>, Sean Christopherson <seanjc@google.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>, David Woodhouse <dwmw2@infradead.org>, Paul Durrant <paul@xen.org>, Shuah Khan <shuah@kernel.org>, kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v10 06/19] KVM: pfncache: stop open-coding offset_in_page() Date: Mon, 4 Dec 2023 14:43:21 +0000 Message-Id: <20231204144334.910-7-paul@xen.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231204144334.910-1-paul@xen.org> References: <20231204144334.910-1-paul@xen.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 04 Dec 2023 06:44:51 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784362924344156001 X-GMAIL-MSGID: 1784362924344156001 |
Series |
KVM: xen: update shared_info and vcpu_info handling
|
|
Commit Message
Paul Durrant
Dec. 4, 2023, 2:43 p.m. UTC
From: Paul Durrant <pdurrant@amazon.com> Some code in pfncache uses offset_in_page() but in other places it is open- coded. Use offset_in_page() consistently everywhere. Signed-off-by: Paul Durrant <pdurrant@amazon.com> Reviewed-by: David Woodhouse <dwmw@amazon.co.uk> --- Cc: Sean Christopherson <seanjc@google.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: David Woodhouse <dwmw2@infradead.org> v8: - New in this version. --- virt/kvm/pfncache.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/virt/kvm/pfncache.c b/virt/kvm/pfncache.c index 6f4b537eb25b..0eeb034d0674 100644 --- a/virt/kvm/pfncache.c +++ b/virt/kvm/pfncache.c @@ -48,7 +48,7 @@ bool kvm_gpc_check(struct gfn_to_pfn_cache *gpc, unsigned long len) if (!gpc->active) return false; - if ((gpc->gpa & ~PAGE_MASK) + len > PAGE_SIZE) + if (offset_in_page(gpc->gpa) + len > PAGE_SIZE) return false; if (gpc->generation != slots->generation || kvm_is_error_hva(gpc->uhva)) @@ -192,7 +192,7 @@ static kvm_pfn_t hva_to_pfn_retry(struct gfn_to_pfn_cache *gpc) gpc->valid = true; gpc->pfn = new_pfn; - gpc->khva = new_khva + (gpc->gpa & ~PAGE_MASK); + gpc->khva = new_khva + offset_in_page(gpc->gpa); /* * Put the reference to the _new_ pfn. The pfn is now tracked by the @@ -213,7 +213,7 @@ static int __kvm_gpc_refresh(struct gfn_to_pfn_cache *gpc, gpa_t gpa, unsigned long len) { struct kvm_memslots *slots = kvm_memslots(gpc->kvm); - unsigned long page_offset = gpa & ~PAGE_MASK; + unsigned long page_offset = offset_in_page(gpa); bool unmap_old = false; unsigned long old_uhva; kvm_pfn_t old_pfn;