Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp371878lqp; Thu, 21 Mar 2024 04:08:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV+PUKGFhTcPivWHSZemO+Rth1tNSyBPtvORJAx4jBktLtZxPzjDFJHgxHpoPZdLs20cvmm1jA8oqGEzRbjI5WMa5TJeJj5rYJ9uzy5gg== X-Google-Smtp-Source: AGHT+IErCTJVWu3rpIX9Gwc6jXGayKXjeCkxYGKMJV9Hd8IaB38p0Jcl1tG9QUTaS0yz4rd1iTiR X-Received: by 2002:a17:90b:24f:b0:29b:af80:7395 with SMTP id fz15-20020a17090b024f00b0029baf807395mr3297070pjb.4.1711019311354; Thu, 21 Mar 2024 04:08:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711019311; cv=pass; d=google.com; s=arc-20160816; b=uvPWpYhtK/ZWFBCbkljlmEzqPCvZdXU6dP+ILV4GcOxDC+EHw/FMMRe45+sQAGEJgt ZItSTeeL3kDoOm+daSSWyIAexadfQKxFauppfTZjXWg8NzaaIPkK5/10FkFWZe4RUBEf k67Ias1jrTKynnuzrpmSGGpzbm29bSoczx5j/Yhsv0vYi/sBoUnj1MhxIJ0yeaDWvYlG bhsRSUZWtXqYmT22q66O7GKnG/o03lPFCCIBKvdm73Dh7BCqrB3vsHpxBMqnyVpT4I43 wpepf1CCw6j45YMwOB1YEwxzjaq8DB8BDjltjUN+l1g2I6RZ9myIAfpz82urLT/gz2X0 6pdw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:references:cc:to :content-language:subject:reply-to:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :from:dkim-signature; bh=LBA/ZrsdEP2mJDzZKy68MDsPNZzNplR+dVmyq9Un4qk=; fh=8yiPBqirA62BAX0g32PkxfQ9bIa8SYYGniY0WaNPgCw=; b=mk8H6XoTn8n2iM+6cLWpsSTKY68poUvbUHMOWOb1Jy2CRV26JCyMB6P1EZfPBExbDp HRE1YGf8UScDRMEdMTV4jk20vIsDYIre3XjGJxQu+xWTSGRX2n4HaLKM5+kvxtTnp8Fx 7pK2L+N8dFpzZ92RR4eu+mWPrSKeizIFC+8c9BNwMkjaCzKfoXH6Erwa8aBlyvhukbpQ 0Djc941f41cphN2XGELNrjbKS1xcUDcvupTJFbERRkZk1KM23A260v87A7jmP7lBf5x2 x4SzPevQWHgTe+JYd+bhKzd03GVU3ozppG+LCj4lJJ7h61uN6lYSi7FDEnfyRxKjllfd xnOg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=IQgnc9nP; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-109921-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109921-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c1-20020a631c41000000b005e430f46834si14179916pgm.19.2024.03.21.04.08.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 04:08:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109921-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=IQgnc9nP; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-109921-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109921-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 997A6283289 for ; Thu, 21 Mar 2024 11:08:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B25D58126; Thu, 21 Mar 2024 11:07:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IQgnc9nP" Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (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 485631CA9A; Thu, 21 Mar 2024 11:07:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711019275; cv=none; b=cPa7QE5juU3NtJhfaNlmSDj+6z8ecUswQKdxuMUrXC07opl4buvbySeBE52zZe0uRtunelvWaM32l/idNrVEiPXBqz3Eq/+TBbHXNeRFTL5/bX1qd5ob/hPXHCauN8AaKf4amSqIT5MfUylYupEO8Qa0ZryiQPBIjKLXBIGDMmQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711019275; c=relaxed/simple; bh=991r5jVPabzsSiBI/2AWFmPQe3N0Culave2SmDvtwig=; h=From:Message-ID:Date:MIME-Version:Subject:To:Cc:References: In-Reply-To:Content-Type; b=q153jhm3EaJw46qKo/b44ulqCTLAJQIA+oZgo6+6WQTgi7D2D9bEAmCMg/3V9oAq8T556RH230X7lFfXI1rkqxdtZTrhSiBt+wIE3EkJV4tm3Q+hb9plNtUscx7fBmChoJ0xZy90vGjSPwnGBycY75BjKYIE1GOf4y88XdWXzjU= 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=IQgnc9nP; arc=none smtp.client-ip=209.85.208.180 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 Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2d094bc2244so11870011fa.1; Thu, 21 Mar 2024 04:07:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711019272; x=1711624072; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:organization:references:cc:to :content-language:subject:reply-to:user-agent:mime-version:date :message-id:from:from:to:cc:subject:date:message-id:reply-to; bh=LBA/ZrsdEP2mJDzZKy68MDsPNZzNplR+dVmyq9Un4qk=; b=IQgnc9nPvZVfyR95ZgpmAoguW5Kus9Rg1ze2NIGHaAwAAQ5Z1SrIzC9Bj/QRpAxjQJ 75CEwsRwdBJpVxVsUj18f6vVcpE1wwXK7oL3IOSG8VOl8DFbQDiGzuaGqbPFRUDcvlXo 9vtXcyk6KLD7RFImYSzT8eQFMjiGzvdGbKPw+mdxx5I6LoIhCfHHwM2OxgqgXfaM3UHL yWy6n5wOJruhsIEhbWMBxpsS5RjvUiPgYAvC5MTdcp3lSuK2+DIYoiFzrWX3auzVuVWp zlJXX5OUGA6GhlRIoHiVStKbVOR0rIAdAfz/nTCDObKz1NgAKOE1yzQaZRyarRYupLez GPvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711019272; x=1711624072; h=content-transfer-encoding:in-reply-to:organization:references:cc:to :content-language:subject:reply-to:user-agent:mime-version:date :message-id:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=LBA/ZrsdEP2mJDzZKy68MDsPNZzNplR+dVmyq9Un4qk=; b=A6C5ynnEyW+7dE4LjoC704hFNOe0dC2yN3H9/hNqj1WXVoBQgphua5Kjy320obqUWK dzbhdyDHF4LwzyKbnGYkQdv1xRnsfpv0bXyZkemm0JlfBh0iqovXf2Nz+3IgQoQtDA0O 27YwpmN8dKi0/i9Kr9nrNk31eWD3np068orgAfiqY80GG+w1tqFnnY/HG1Xy/Zahft0P 65tNvivuSMqGRqAQckVIQ08edMxB+OX+F6XNZPmAY/K0g8TAEwP4lnUz/TSEaRHUfLmP l+i+8T7vw/n+m0PXAcBF08iu3fv+FGCMVapVK4n76TX+B1MmFcc/AbrVT5w0NPXqpwCo lhRQ== X-Forwarded-Encrypted: i=1; AJvYcCU4Wk8Pq7ADK/4JF6YyQG2kmIAbx66dkcoapX9PaYA4otHmAeZP3nsgPQT0WV0YjWAya8NjXB1cnUSxn3XRLS3t01t6SbD8ZIcYySYa X-Gm-Message-State: AOJu0Yza3QwigmT36pUqKYwvp7Sm/ajnGgvDwnZ8l9F2SgfBY7T5HnOt jeupy3qm1VUVi3OtVU78qoI09IpAnwzyu9KytCwJfn7/7HiraxCf X-Received: by 2002:ac2:54b5:0:b0:513:426e:625 with SMTP id w21-20020ac254b5000000b00513426e0625mr5007201lfk.22.1711019272230; Thu, 21 Mar 2024 04:07:52 -0700 (PDT) Received: from [192.168.16.136] (54-240-197-226.amazon.com. [54.240.197.226]) by smtp.gmail.com with ESMTPSA id fl25-20020a05600c0b9900b00414778ca80fsm122464wmb.16.2024.03.21.04.07.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Mar 2024 04:07:51 -0700 (PDT) From: Paul Durrant X-Google-Original-From: Paul Durrant Message-ID: Date: Thu, 21 Mar 2024 11:07:50 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Reply-To: paul@xen.org Subject: Re: [PATCH 1/3] KVM: Add helpers to consolidate gfn_to_pfn_cache's page split check Content-Language: en-US To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+106a4f72b0474e1d1b33@syzkaller.appspotmail.com, David Woodhouse References: <20240320001542.3203871-1-seanjc@google.com> <20240320001542.3203871-2-seanjc@google.com> Organization: Xen Project In-Reply-To: <20240320001542.3203871-2-seanjc@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 20/03/2024 00:15, Sean Christopherson wrote: > Add a helper to check that the incoming length for a gfn_to_pfn_cache is > valid with respect to the cache's GPA and/or HVA. To avoid activating a > cache with a bogus GPA, a future fix will fork the page split check in > the inner refresh path into activate() and the public rerfresh() APIs, at nit: typo > which point KVM will check the length in three separate places. > > Deliberately keep the "page offset" logic open coded, as the only other > path that consumes the offset, __kvm_gpc_refresh(), already needs to > differentiate between GPA-based and HVA-based caches, and it's not obvious > that using a helper is a net positive in overall code readability. > > Note, for GPA-based caches, this has a subtle side effect of using the GPA > instead of the resolved HVA in the check() path, but that should be a nop > as the HVA offset is derived from the GPA, i.e. the two offsets are > identical, barring a KVM bug. > > Signed-off-by: Sean Christopherson > --- > virt/kvm/pfncache.c | 27 +++++++++++++++++++-------- > 1 file changed, 19 insertions(+), 8 deletions(-) > Reviewed-by: Paul Durrant