Message ID | 20230914084946.200043-5-paul@xen.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp249013vqi; Thu, 14 Sep 2023 03:31:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFwBKKv+liJYzIfd/3hztMasFcBr822leSBubTgAH06spFMQ2ASLUUHjmxvDoBPdK51fh+x X-Received: by 2002:a17:902:bb8f:b0:1c4:c5d:d7fa with SMTP id m15-20020a170902bb8f00b001c40c5dd7famr1214882pls.45.1694687511059; Thu, 14 Sep 2023 03:31:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694687511; cv=none; d=google.com; s=arc-20160816; b=ZLSrTkKa7eHpMeaDEI8lihbjjlMx2iqkQSIIqh4rzYkymd1EUB/bulacY7NO55b1qx Wbq9gIobGIzpODIZDwLZ1oc0Ym6LyLCdelYjVJKHzeglJJquCX8BwJrbaCgJinUeKvLm Aq6/UGgnlmoWlv7X47WCzUyLRQd0P3/r4B61JbEQjrkULC0/VSCCBLdgtMk2qQwoWlqy L63FTN/LTW+3XgFDu+xnV6RpL6MjSvrzMOnFfnYtZlmDJoaeyZHTyhJZ0DovhE/uCmMn 4NcbKlmmWw0u7pdhxQgsnXS2WjQaIJ/aAUQVhxZomc8lrHSsbLqDd953/tF5tc7vTPVP iNdw== 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=9p3EjojVRcDnVHSKvpUes+XfyD1e4JyIwNQ5PTtGcrY=; fh=garbXx6xThcytiY3nDlsqHTysvuL2ydFqtzT1pbUU/Y=; b=QNXfTR4+wVi/gLUUhGgWJ8vEoHpxBliNWa5F3tJxv6QRgEBhpit+zY+Ehq5dMXFgz4 t1PIDJJVS0pO+LeDA3CEs4EzafpOFTICYacYN5t3qXTbpDKWS45AHZ7Y1sRxo/8CB1nR X7vg5Ed/mjC9VF2ezyLqYU2xlwJEDV9CC1lebEA+cwtJQWDTxcesK7/qmStwBUk4A5zp n1UOL3BHSXIemlzK+VXZ8ET7/WVCjjp+6PAZ7sWLUbATqTqu1BzCd2+gd4+m1LFNVN+X FO8oNTGps2HkJFSWR3hQruki8zMVHlIkHKOHmeH5ju94SvEu3aHDh40+LpFdYstVhBUc LkCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=iaGoPaMU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id n10-20020a170902e54a00b001b89fd6bec4si1486645plf.144.2023.09.14.03.31.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 03:31:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=iaGoPaMU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 93EA582DAFC1; Thu, 14 Sep 2023 02:07:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237138AbjINJHb (ORCPT <rfc822;chrisfriedt@gmail.com> + 35 others); Thu, 14 Sep 2023 05:07:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236831AbjINJHW (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 14 Sep 2023 05:07:22 -0400 Received: from mail.xenproject.org (mail.xenproject.org [104.130.215.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EB4A1BF8; Thu, 14 Sep 2023 02:07:18 -0700 (PDT) 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:Cc:To:From; bh=9p3EjojVRcDnVHSKvpUes+XfyD1e4JyIwNQ5PTtGcrY=; b=iaGoPaMU1xJDSwLQtlFxK98q7w 9gB7UIN7MNlXhzpjT49l8Og3mntPxeCxNaqhwfldq7mC5LrcXs4mOSsHUnYJpMNHzv9WG9wkfjsDi 9OAL2QpTuseE7UF7Xf8cvniJ+r6aXUbKe8DPtPFmot/SwED8zjXa6EVZTpQcWQ0lTAhI=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from <paul@xen.org>) id 1qgi3J-0001ij-Ab; Thu, 14 Sep 2023 08:50:21 +0000 Received: from ec2-63-33-11-17.eu-west-1.compute.amazonaws.com ([63.33.11.17] 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 1qgi3J-0002T9-3L; Thu, 14 Sep 2023 08:50:21 +0000 From: Paul Durrant <paul@xen.org> To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Paul Durrant <pdurrant@amazon.com>, Paolo Bonzini <pbonzini@redhat.com>, David Woodhouse <dwmw2@infradead.org> Subject: [PATCH 4/8] KVM: pfncache: base offset check on khva rather than gpa Date: Thu, 14 Sep 2023 08:49:42 +0000 Message-Id: <20230914084946.200043-5-paul@xen.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230914084946.200043-1-paul@xen.org> References: <20230914084946.200043-1-paul@xen.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 (fry.vger.email [0.0.0.0]); Thu, 14 Sep 2023 02:07:41 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777008651085593011 X-GMAIL-MSGID: 1777008651085593011 |
Series |
KVM: xen: update shared_info and vcpu_info handling
|
|
Commit Message
Paul Durrant
Sept. 14, 2023, 8:49 a.m. UTC
From: Paul Durrant <pdurrant@amazon.com> After a subsequent patch, the gpa may not always be set whereas khva will (as long as the cache valid flag is also set). Signed-off-by: Paul Durrant <pdurrant@amazon.com> --- Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: David Woodhouse <dwmw2@infradead.org> --- virt/kvm/pfncache.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Comments
On Thu, 2023-09-14 at 08:49 +0000, Paul Durrant wrote: > From: Paul Durrant <pdurrant@amazon.com> > > After a subsequent patch, the gpa may not always be set whereas khva will > (as long as the cache valid flag is also set). > No functional change intended. > Signed-off-by: Paul Durrant <pdurrant@amazon.com> Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>
diff --git a/virt/kvm/pfncache.c b/virt/kvm/pfncache.c index 17afbb464a70..37bcb4399780 100644 --- a/virt/kvm/pfncache.c +++ b/virt/kvm/pfncache.c @@ -83,15 +83,18 @@ 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 (gpc->generation != slots->generation) return false; - if (gpc->generation != slots->generation || kvm_is_error_hva(gpc->uhva)) + if (kvm_is_error_hva(gpc->uhva)) return false; if (!gpc->valid) return false; + if (offset_in_page(gpc->khva) + len > PAGE_SIZE) + return false; + return true; } EXPORT_SYMBOL_GPL(kvm_gpc_check);