Message ID | 20240215152916.1158-7-paul@xen.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-67188-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp484976dyb; Thu, 15 Feb 2024 07:41:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXZlGXo5hSLJsK1qf0DJ0TzT7rdVTN0zI//HVG/BH/9BE3MW9hb2qiNt1NOotzmoni4cJd/JUFMSGn/F0VmwJ6D1Mx9ZA== X-Google-Smtp-Source: AGHT+IEIyKag3vyku1QfGDe+1WjCz1BpO8j14hg4SPMshU1+9Chc0aZlG7lpGMxXvFekUgqpgZlu X-Received: by 2002:a05:6512:344d:b0:511:ae1b:eea9 with SMTP id j13-20020a056512344d00b00511ae1beea9mr1505694lfr.56.1708011696095; Thu, 15 Feb 2024 07:41:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708011696; cv=pass; d=google.com; s=arc-20160816; b=qwDoMKGDT4W6rkcDSloCRS2D6M0xMLV83vvtSYAwXUFmEkYFGEJtxybIebjtyz3gxq AK0T/ya7zY8xOmxXaZpKgecaNkt/Z6fdG6sVIhqAC++La1eruX17vUyhYhZJNam9R6HK 8p4LuMh6TDw8QWTKsQ2StVQDP2J9fhQ3bpM4yValxUpsRTytw5VKGebyBnwV6s84xE+u Gf/MLgbdwiKpvE9PDZA3jlyw61HeqDHuoTtxxsm2rpwmxe/uPSQn5hJbYaF+twu8I10J 1rFTWB83i/JBWvTn/WlwJLwkPG6knf1CIf1iPiua/Esd0/SVs/aB89j5ICDqYakWIOJ/ eC/Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=iyqOFrP3aGKoiCQ7WXZlsE4e+dflFfzsWYBVMlCow44=; fh=NrOggL3VZvuSFh5W9Wj2+kLgS4v0nogfnAWvBJoouXQ=; b=WATU4uNur7M4rdMwyAiO7zULDAOiZ3gonrMMsus55R742K4f+A3vqacd7xBMlWp9hK RCGoVCk3AdiOrE3mAZqCVqWhPVAJuS7kzH2KEuG6J0+/U9mLWRr+J5YEe3aSqZab/HLk FpqWwkaVLpZUu0jM/lfXLP1qkrDb2VW3UR3vZSRF9AJGJPBAxLeLvx37vRk7LusEQsVP smBmMHMn9QbSzSJgR++FG17g3WdNKKMxJqN+MlyPsarXiWNV7P2+dgWP5qO4GO35qFcC tou+gm9YYyycOWD11vRdLNCmsysr5TbdIrfhyZLEd7I6iJlq16xpruV5vFQpf6JeoGKz SsEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=SPALBYED; arc=pass (i=1 spf=pass spfdomain=xen.org dkim=pass dkdomain=xen.org); spf=pass (google.com: domain of linux-kernel+bounces-67188-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67188-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id s10-20020a056402164a00b00561ead8d990si735601edx.171.2024.02.15.07.41.35 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 07:41:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67188-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@xen.org header.s=20200302mail header.b=SPALBYED; arc=pass (i=1 spf=pass spfdomain=xen.org dkim=pass dkdomain=xen.org); spf=pass (google.com: domain of linux-kernel+bounces-67188-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67188-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D08141F2BB41 for <ouuuleilei@gmail.com>; Thu, 15 Feb 2024 15:33:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 162A2136641; Thu, 15 Feb 2024 15:30:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xen.org header.i=@xen.org header.b="SPALBYED" Received: from mail.xenproject.org (mail.xenproject.org [104.130.215.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 227751353E9; Thu, 15 Feb 2024 15:30:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=104.130.215.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708011044; cv=none; b=K/wdrhrYeVzxdirj3eTaPVE19dA1+Xvajy53kRblaqNpHVhDh+SmgTCMzDBzT8RJqBdLZ9HvcmbJhvs/TLIUeJCxzBxxdgtSYxtAhmAQHb76+wb+AAqNCVWLUjbx+erf1cl49HkDxkBXX68rl3DNrUmVCesHYCsHyYUaTrtFdvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708011044; c=relaxed/simple; bh=gT5VN2sbvdL3jCTSIc7ZtyXxmGhSdK5e+j4jt7VI3OY=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=H7vqYNqBsUSEOjLEhGHl7WyzBCCYjzU7QKsNDqdgsXUzrqfWMiLxrLeEbA+xhsKNYmitKtZNKuAE1YmD8+wV4oGCEHhVn06EWdlPSRzbK24JDIFgTSyv67GU9V57Kd+5Vz+3H4Q0iqF3W5RrrUNh0izuQ8C8JSYNtBLwal533AM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org; spf=pass smtp.mailfrom=xen.org; dkim=pass (1024-bit key) header.d=xen.org header.i=@xen.org header.b=SPALBYED; arc=none smtp.client-ip=104.130.215.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xen.org 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=SPALBYEDZzHykvolKxo2MPaEi+ ZgHULF9iRjLW1gy61KzLsZ4kjeRn0MaQLW0YW4YWw1tK7slG6yg/iuleUrQ9x7sxoByc4+bELCB/r omg5TTg7RpduSlaOsVIjl7sfDwdcUdT+RYkM76wxo2OYlytNruasQl9RUGdrQdIvbS7s=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from <paul@xen.org>) id 1radgu-0001FE-5A; Thu, 15 Feb 2024 15:30:24 +0000 Received: from 54-240-197-226.amazon.com ([54.240.197.226] 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 1radgt-00089r-Si; Thu, 15 Feb 2024 15:30:24 +0000 From: Paul Durrant <paul@xen.org> To: Paolo Bonzini <pbonzini@redhat.com>, Jonathan Corbet <corbet@lwn.net>, Christian Borntraeger <borntraeger@linux.ibm.com>, Janosch Frank <frankja@linux.ibm.com>, Claudio Imbrenda <imbrenda@linux.ibm.com>, David Hildenbrand <david@redhat.com>, Heiko Carstens <hca@linux.ibm.com>, Vasily Gorbik <gor@linux.ibm.com>, Alexander Gordeev <agordeev@linux.ibm.com>, Sven Schnelle <svens@linux.ibm.com>, 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-s390@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v13 06/21] KVM: pfncache: stop open-coding offset_in_page() Date: Thu, 15 Feb 2024 15:29:01 +0000 Message-Id: <20240215152916.1158-7-paul@xen.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215152916.1158-1-paul@xen.org> References: <20240215152916.1158-1-paul@xen.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790980071915611837 X-GMAIL-MSGID: 1790980071915611837 |
Series |
KVM: xen: update shared_info and vcpu_info handling
|
|
Commit Message
Paul Durrant
Feb. 15, 2024, 3:29 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;