From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 AB6472586C2 for ; Thu, 5 Mar 2026 19:46:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772740007; cv=none; b=tyROX/Q4++VKUhpeA6MDDekhdFEsFGj8lb5DqFOttTN6zvbmcCYgq/kF1pKAxZqRBvqA4fCEqbXn/DIAnCvDwcGLziSesMb7H2Rr9NqJShyXt/tXZVWZURwOFOsfCKzLbng3nfIEcobN43StDG5wJ4c+d9fTgCAqehnbDVAF0fo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772740007; c=relaxed/simple; bh=JH15yDfCbqJbRHQkR4wgBRmd6IFbUbM1meiQNP0Wrgk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=h5PyLOsEBi7s1JHq7wbTZ54JpIFIWhXO0xpnZ07M55gsj6XbwQOzgJ4KybW8beR7+nrx/xEJzgupVAL3hjZFnhj4O6vPcRZdRN61tx3PXVbTPZBTopbh801FCIJMKBbnpQqFuH4AOl0Yp5vcTfFREXY/OP1WT4yj+gPlVUB/cTs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=RK6KUkvN; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RK6KUkvN" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-3598d4b19deso19872537a91.2 for ; Thu, 05 Mar 2026 11:46:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772740006; x=1773344806; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=Wjn38o8lsg+c2mqWGvvOi9PSLqHeZjHOFWYbF5i1GhM=; b=RK6KUkvN1u2z65rHg/R5lkDQRU28GtYT93K9cjmu1M00lGc3WmYRf/CCOopFcAvYJh UmUOHwmpA+lNq3nz3bioyefpFmhpASipfYk7I4NvetfrLLdGgv9STmOekmUwkzuU3uKg B1XND1OXb4jpkUAnXSJ9K/k/5JyrO7udNPR20Tbb6VmTsfeLgQSXsGWdZ1ElTSPEwHeC GqTF99MUMlKDUTuSIUWGbWVLJ8VcgA/dGNblvUFFbvXwScC/QWlFKTdW6R1wdfhjiVmZ EWH5c+l5nUBk1aOUpm1IKTcjw5T518l0+qj/+T+zekKd3V3ELb3Vdjb3fvpqzG328JT6 HERQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772740006; x=1773344806; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=Wjn38o8lsg+c2mqWGvvOi9PSLqHeZjHOFWYbF5i1GhM=; b=S8CYgngEA/0uhn79at5rDGwG4wievYon0YI4sVglamE8cVHD1iBcnCn48B0WMFnlyY rPuEywolVZruBFPIxN5SySwyCbj3CgIhh1rwUm1lKG0QlE/NCMktG2pDRFgwyf7IQ0AP R/nRpksXRwDIiYjdBETateCpEHJZBBLAuZd7/C7CKuCVCPKCSYqlPE09Dw+P856khn6X 8dZTqFfrs8G7mg2ExeWGw28nTFqrOVU8UyIs/o7nU/nxkA2/fpn0HJB5UdBVavXUAgtx +qPPpaNBAMJoEvap5NW5/pTgvuIvsGk3pEkO0fSx2mUHvlZnZgFwXvG3uzalLl0LjU5E hJNA== X-Forwarded-Encrypted: i=1; AJvYcCUJ6s0QgU1CCQHdHZkxoJBBF6DwsB8VRncEsuN42ZBK0PLxoALpOvkdtP4Oad8wNZ5S/3oGUKoM6Yym6q0=@vger.kernel.org X-Gm-Message-State: AOJu0YyPf7sS3ZTsodD8nYKw/uQlXITWO3wdvEDzUeGggqKltJuJvjPq RfcJlNkzU63Csz+LFvQwcl0Ibbg8YL6wJ8+IfqXKNsJTiSuuFiQGfLicSHwyUdij5RGFSVjD/n9 xiRGTNg== X-Received: from pjbcu12.prod.google.com ([2002:a17:90a:fa8c:b0:359:9633:e147]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90a:d403:b0:356:41c2:897d with SMTP id 98e67ed59e1d1-359bb39a0c4mr534663a91.8.1772740005862; Thu, 05 Mar 2026 11:46:45 -0800 (PST) Date: Thu, 5 Mar 2026 11:46:44 -0800 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260224071822.369326-1-chengkev@google.com> <20260224071822.369326-3-chengkev@google.com> Message-ID: Subject: Re: [PATCH V2 2/4] KVM: SVM: Fix nested NPF injection to set PFERR_GUEST_{PAGE,FINAL}_MASK From: Sean Christopherson To: Kevin Cheng Cc: pbonzini@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, yosry.ahmed@linux.dev Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Wed, Mar 04, 2026, Kevin Cheng wrote: > On Tue, Feb 24, 2026 at 11:42=E2=80=AFAM Sean Christopherson wrote: > > This is all kinds of messy. KVM _appears_ to still rely on the hardwar= e-reported > > address + error_code > > > > if (vmcb->control.exit_code !=3D SVM_EXIT_NPF) { > > vmcb->control.exit_info_1 =3D fault->error_code; > > vmcb->control.exit_info_2 =3D fault->address; > > } > > > > But then drops bits 31:0 in favor of the fault error code. Then even m= ore > > bizarrely, bitwise-ORs bits 63:32 and WARNs if multiple bits in > > PFERR_GUEST_FAULT_STAGE_MASK are set. In practice, the bitwise-OR of 6= 3:32 is > > _only_ going to affect PFERR_GUEST_FAULT_STAGE_MASK, because the other = defined > > bits are all specific to SNP, and KVM doesn't support nested virtualiza= tion for > > SEV+. > > > > So I don't understand why this isn't simply: > > > > vmcb->control.exit_code =3D SVM_EXIT_NPF; > > vmcb->control.exit_info_1 =3D fault->error_code; > > >=20 > Hmmm yes I do think it can be replaced by this but we would also need > to grab the address from the walker. So >=20 > vmcb->control.exit_code =3D SVM_EXIT_NPF; > vmcb->control.exit_info_1 =3D fault->error_code; > vmcb->control.exit_info_2 =3D fault->address; >=20 > For example, in the selftest that I wrote we should be populating the > exit_info_2 with the faulting address from the walker, not the > original hardware reported address which is related to IO. Yeah, sorry for the confusion. I wasn't saying _don't_ include the address= , I was just pointing out that the error_code handling can be much simpler.