From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 482343A6B61 for ; Sat, 4 Apr 2026 09:40:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775295624; cv=none; b=Fub88dchfPCpXKbAdPrW/X6JN+k4l/IC/iNzPWcEmh+99Aohc4RsWfiMpRz8Uz+pW6EvQqOiUnGYxi7ZfCkv1aaJ2A/lV11dqI546XZ/4MpY/VltcX+c1sof5odfRgbBK1DTww+3MvYC4XXi2mSIAC53Rp4kTiUW8j35wesC6Mk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775295624; c=relaxed/simple; bh=XDXXCvBuP+BedXOB/xJSS7nMwuoIr0SIXDhnUXQY4kw=; h=From:To:Cc:Subject:In-Reply-To:Date:Message-ID:References; b=I6vbPUcNQ5PHTtt0iKsvEN1HdfhABcm1ivnKwCNPlxXhhfPcRodZmv0XurwU959OAmaI7utLhBhjZLHeVClmPqiwaG6ACvUKs/fdwpLonct3a7IQQSuY+Becfu8EByl46Cp7ttM3fJ0Gfvca0sEkYsvLSLZ3LMBqlUcz0GrXutU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MdjZEwjh; arc=none smtp.client-ip=209.85.215.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MdjZEwjh" Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-c76b95e652bso770961a12.3 for ; Sat, 04 Apr 2026 02:40:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775295619; x=1775900419; darn=vger.kernel.org; h=references:message-id:date:in-reply-to:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=rOaxQXfX6SiiuBlcP8X1nQXWObPEsgiGGDciqZtKDLA=; b=MdjZEwjhhjDeVQBpJUdGFjryWTfkjawv2IsHZtPE3ccALMo/uiHRFPDbWtUKVIYSLY Kb7cH5sTS14s7F9rr4IlTd4BEVnSUtv5JGApCn4c71Wqkq48f1x+sC3F4CfceiIAndWh pLpxZ1AoDcYVhKSTBsM9tTnpHXdAwIMBaa3BMR1Kpn+XMhTtCXYg+7rCqUcWgvPR/4Ms zYI+w4ZZFCO8mlJrVeNUAr42ZMnfSxH+fzLuJY37tBLFw+ufHyheYQsJ4pbnfUe6auHl QIIRurGLmPpkmf0C8Mvx8fBq2N2tQJ+o71ImlVK2TYemsc+Y4U5gDLSiER2iJaSkWz/B 5G2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775295619; x=1775900419; h=references:message-id:date:in-reply-to:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rOaxQXfX6SiiuBlcP8X1nQXWObPEsgiGGDciqZtKDLA=; b=FilD7hJ3zmJmpatfUctXUuHuG2vN+joSA+Natta8uO4U/VLpcRCjsx96v+1PrfCXoP sTWC9lPWeH89DvaAqh8TD1SvLAV6/ju4LlLq5d34/1tlxFpZQPpNph8VKe7FxFjozVdj QJ5f3Ap40sbn43nLsHV4uNmjOodASNkiVvedTGiH65zih2o3hzdLZ2iYZEOX8r5b9drW XF/nzNt1/8zlZ0XU2IYmRPS/e7r/eKnfgUuy+aXFfLjKfa5nTqiwovMCwHfer3x4okWF 1YPsuHz3cHB07rbIo+dMsV8d8CnEpbZtvU8mlHV39QMPwlHu8X6aO1vdByXKbRIQh9YM tnMg== X-Forwarded-Encrypted: i=1; AJvYcCWQUjB0vYf7hoIhaUVMD3xLNteqpuX9RZHhH5Ey4GjtvlDpf+fvQmvbAIKfcHDZW8YJpXZe81Wyi5XdZDs=@vger.kernel.org X-Gm-Message-State: AOJu0Yz7F5qYCohThr4X4+5kNdw+U4QWf05qupHNZCIFg/KJZiKSTotB NHHezkhsKPHKWp+bUv+C57lEKcWpuakxIO7ZDpItpcM0iKc0Q1HvwNJw X-Gm-Gg: AeBDiesX5IGFfvfH97U3PlRz98b8SgqoNJJzecl2f3xbXQZs2drN9MS/P2OKgMj9szZ k4WrX14y+yL+3jqlO/9NzBDFexdUxbDdwXHKIL+HkdssLvSFP9RN1Logz7AbIMEYgee80Nkfjab 0dK4wk9dRvM8GqnFt9HxWdtK3Vf6+n+t4KYhPp/SqAHqrKHsaPMWsTTc4BjTHa/U8MIiyWpqI66 K5BDgBs0TEeaHy+m1UwE1x+MwUC+0pS3qv7EDYaueUzlGNmcOYvlfZ9v5FAw8hknuD5KUjkUOOl wU1REUzSY44wGIN4p7wZeJmAODQXN+S+QdnnYrNR7ev52bqLnoJ5yXA0DfkGGOojYJ0hmONw8l+ 7ybYOy22JqL4Xmop/9SEAAoTym+YVhJK1fUEqC4m7elolDjHAW26eWHWR7zIqQzgdj4APC5+uPt VLRIFBqInb5vbC/81OJVea9Q== X-Received: by 2002:a05:6a20:430b:b0:398:6ea8:21d2 with SMTP id adf61e73a8af0-39f2ed8d9e7mr6111236637.19.1775295619301; Sat, 04 Apr 2026 02:40:19 -0700 (PDT) Received: from pve-server ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c76c647792bsm7698445a12.6.2026.04.04.02.40.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Apr 2026 02:40:18 -0700 (PDT) From: Ritesh Harjani (IBM) To: Yosry Ahmed , Peter Fang Cc: Paolo Bonzini , Sean Christopherson , Madhavan Srinivasan , Nicholas Piggin , kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, KarimAllah Ahmed , Konrad Rzeszutek Wilk Subject: Re: [PATCH] KVM: Fix kvm_vcpu_map[_readonly]() function prototypes In-Reply-To: Date: Sat, 04 Apr 2026 15:07:01 +0530 Message-ID: <7bqnm5he.ritesh.list@gmail.com> References: <20260325092001.613025-1-peter.fang@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Yosry Ahmed writes: > On Wed, Mar 25, 2026 at 02:15:11AM -0700, Peter Fang wrote: >> kvm_vcpu_map() and kvm_vcpu_map_readonly() should take a gfn instead of >> a gpa. This appears to be a result of the original kvm_vcpu_map() being >> declared with the wrong function prototype in kvm_host.h, even though >> it was correct in the actual implementation in kvm_main.c. >> >> No actual harm has been done yet as all of the call sites are correctly >> passing in a gfn. Plus, both gfn_t and gpa_t are typedef'd to u64 so >> this change shouldn't have any functional impact. >> >> Compile-tested on x86 and ppc, which are the current users of these >> interfaces. Mostly a mechanical change. I had looked at ppc call site and looks ok to me. >> >> Fixes: e45adf665a53 ("KVM: Introduce a new guest mapping API") >> Cc: KarimAllah Ahmed >> Cc: Konrad Rzeszutek Wilk >> Signed-off-by: Peter Fang > > Most callers are converting a GPA to a GFN, I wonder if we should make > the function take in a GPA instead? But then we'll need to the GPA not > being aligned to a page boundary (either do gpa_to_gfn() in > __kvm_vcpu_map() or fail if it's not aligned). > > Not sure if that's a net improvement, mostly thinking out loud here. The suggestion from Yosry and Sean sounds good too. Instead of every caller of kvm_vcpu_map() doing gpa_to_gfn(), we may as well make kvm_vcpu_map() accept gpa_t instead and do the gpa_to_gfn() inside kvm_vcpu_map() in the call to __kvm_vcpu_map(vcpu, gpa_to_gfn(gpa),...), or within __kvm_vcpu_map() which is fine too, however, the former is a better approach, IMO. -ritesh