Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2652920rbb; Wed, 28 Feb 2024 08:23:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW79xWZb59GaPrjmqj5Zl7hlC6Fi8C0Qb0wqd61B8FUMt+RcHp2IUMnXmOSUdJFHdjWqd97hIljuYYdKTY5G9Hy2Ns5bQ89hNuBfifQ2A== X-Google-Smtp-Source: AGHT+IEbRT08nGZHttWE2zWyHZIKnXf1kRLMq36b//POf+YZ+thr3FoHUmGHcwIM3cK4782FsUM4 X-Received: by 2002:a17:906:f249:b0:a44:205f:8a35 with SMTP id gy9-20020a170906f24900b00a44205f8a35mr117017ejb.70.1709137384433; Wed, 28 Feb 2024 08:23:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709137384; cv=pass; d=google.com; s=arc-20160816; b=EV/1EsM4/PlRB0iGLSsSgNZpCqV1uJRwuzE2aVLwVMgVsaEwz1/bWiCMPaZnXIP8Tp 9tJ7HlejkNM0MB5xfJq2SbuJvb0EPchUEr4XfdyKfRiL4lwoBAIObhEOqXAkySwPIJ9A U9FSsY1DUQLk0rgBHnKSVgRzdctXIsfthkTvS1ri7tK6SqDhXNdKdyxKQuR8nSk6gV0Y eyaTaejqs2xYqjkA9IUbPjszO08kZUYNDoY7pkX+mZ7vFcuSyhJ0ngnuUiFUaaCnt/wT WkxZknXDXXVXdNeWySRwgFTPNBJrgetXLrJHBzitFWMQOzbjILs5DtMbAsvYLM0PxZ+5 u8Yw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=EgTRs3gBzwFgs+8ahOL08VjadrSfP5/zA+WOBgwRs50=; fh=rYC84JuTDLaNLgfnXmaAtq3EjiCBW+dEgO1gtRXeuY0=; b=ze3bCNrftXLX3pPYyN+ICxi/aj4dkYKRgY1Gl76w2iC2DjmYxwyGHj4oSwXRFfKZTT MRyDWNa8Gfl/2nsYpcrPcloi+C0+qi2Rx20Haml2LEpmpzgkU64bLlf/exHrAtgae7sy Cnc/ZzKn9GXLc46vTY1dwWWG9Ay+i6813aQxFeWHymHaPEbES0INhvot5sQTEPKtp3CO 3GytY/ZteIUuiEpTUYD/Jl3tweV1E6nRQgXwBWpebVaRgqA1dPkry22ZK38huWjqb2oB dZ88z2jy9xCx/TLkI+AMJa4wk0QDK/gcIUwVjjGVSIhxCPlXLxWdZanfWkk/wB61KHWj kMnQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=sKxY6qT0; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-85355-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85355-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id w14-20020a170906b18e00b00a43a4a14776si1768550ejy.605.2024.02.28.08.23.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 08:23:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85355-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=sKxY6qT0; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-85355-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85355-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0B5EF1F2336C for ; Wed, 28 Feb 2024 16:23:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D700A3FB91; Wed, 28 Feb 2024 16:22:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sKxY6qT0" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 A01D73FB83 for ; Wed, 28 Feb 2024 16:22:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709137374; cv=none; b=RVsI2XQ34X1S/YqySZLsUiOwEYgUtSbluFBtHKcj6quZdmbbgHUA7hv38gXl3C7RH/DcMXdEiEMBStzlSyKvLjUMCjkqnURhEUPkGxg5Ir9//c2FrtO7cabrzYxjCU2QT10ZUhCkLQvC+EC7R6KYhej8VQLDQjwglwA05U9fkyQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709137374; c=relaxed/simple; bh=AZtli4Ue/PpvWMofqUA1KwJ8G1q3Xq+ZA8rm+RkDid0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=LPPkX0oKymvf1sfxbHgL3eBWvbh7OM1mrKXMLkTd8HiOpcoB3P2Am+gXrrvLkiGkwrMmmVETY56b0UzOlCGZEpvoc4E3a1F2AJmtQ4NTbk9LirJWg4VT96vUOYKDcemIplFRsxdp4Y0y1Fcwp6CFSnXjXjj1bZtE3mCq/iq6XNI= 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=sKxY6qT0; arc=none smtp.client-ip=209.85.128.202 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 Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-608ac8c5781so98987137b3.3 for ; Wed, 28 Feb 2024 08:22:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709137371; x=1709742171; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=EgTRs3gBzwFgs+8ahOL08VjadrSfP5/zA+WOBgwRs50=; b=sKxY6qT0fvz7nKDKm5/pWTX61Ss3wSNGlSJQp8dYwq7hei4ME/CbEM5AB0uYHCY7Wq d98VYoNldRGwsHU9WI2y6nrqGuotn7KxmAnox/rGB51kb4dnKth0YETX+NXXmbG7cgfI q0o8YBSGrvPaz5TXUdwp+An42YoU0F1jSHY7QXBwGgTGc93GfWolaKxc3zUkHCJulId7 KSZkqwKOxSkgXoxzJoWI/2Rx3f53j6OG7MiaLsXkwKm1NZXgR4AIS3GFJa1BO3OgpY5D OY9JJ14RP54SGj9jphKAzQSAAprmYfP8q9Q3A5moG8cx1o2W+5GL40pnBHZvxGmmVGCg Nv8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709137371; x=1709742171; h=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=EgTRs3gBzwFgs+8ahOL08VjadrSfP5/zA+WOBgwRs50=; b=Iou5UrCJxkYL5x4q53LUngSiuhbPK4ebpoCH26QdQaDo3X4BFeN50Cw3UJIqx0mB5s Vi3swhDgghV5JMla2aZlyGAO0k+NQEqJiaNowZAPMnol+5Kx69Hp4+5LzDcBCIXBn/rC SVchcBZZEhkH8u2kyfe2ZEMx1GRZ4BDSo/PYw5i2NRxwXX2HAtwBQvNJoiAc6z0mlhlm iKSFeTNXdmGp2zpHLsJ8Rtmo3k3j07uXg/Gk3/eKlFCpP6RAJ8jqcrLB0duH9XYjCTHs 9+RMgjAjYJXMURAohQ1dNpwlDQBOOUQPPehd/fmAHrxi+nL6yilJtT2xhRYKqbU0aSzN JQDA== X-Forwarded-Encrypted: i=1; AJvYcCXNJ/Q3W1i3iH9OoT+0Q3EQ1O+w/WM9hHCyL0Er3+3zCUZ+14wtQ5rb5UixIvQvXmD9p+Nr8oUwAqYIeO9UEP37j1flPHzqIfVh2Z59 X-Gm-Message-State: AOJu0Ywmhs1dpo4Nla087siQUftwqfldxeNi2Z5pZtOAMo+/sC0+8+VM /1E1HYCzn0wNIDkEfhrPVbMb7PRDkxorDGjIfwKoox1naGjtUmnvuEtI+4B/9lUb2LiZboLNxER Aqg== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:1507:b0:dc6:e1ed:bd1a with SMTP id q7-20020a056902150700b00dc6e1edbd1amr823087ybu.2.1709137371681; Wed, 28 Feb 2024 08:22:51 -0800 (PST) Date: Wed, 28 Feb 2024 08:22:50 -0800 In-Reply-To: <6c10e17a-b1f2-c587-fbdd-85d15256b507@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240228024147.41573-1-seanjc@google.com> <20240228024147.41573-5-seanjc@google.com> <6c10e17a-b1f2-c587-fbdd-85d15256b507@oracle.com> Message-ID: Subject: Re: [PATCH 04/16] KVM: x86/mmu: Pass full 64-bit error code when handling page faults From: Sean Christopherson To: Dongli Zhang Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yan Zhao , Isaku Yamahata , Michael Roth , Yu Zhang , Chao Peng , Fuad Tabba , David Matlack Content-Type: text/plain; charset="us-ascii" On Tue, Feb 27, 2024, Dongli Zhang wrote: > > > On 2/27/24 18:41, Sean Christopherson wrote: > > From: Isaku Yamahata > > > > Plumb the full 64-bit error code throughout the page fault handling code > > so that KVM can use the upper 32 bits, e.g. SNP's PFERR_GUEST_ENC_MASK > > will be used to determine whether or not a fault is private vs. shared. > > > > Note, passing the 64-bit error code to FNAME(walk_addr)() does NOT change > > the behavior of permission_fault() when invoked in the page fault path, as > > KVM explicitly clears PFERR_IMPLICIT_ACCESS in kvm_mmu_page_fault(). > > May this lead to a WARN_ON_ONCE? > > 5843 int noinline kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, > u64 error_code, > 5844 void *insn, int insn_len) > 5845 { > ... ... > 5856 */ > 5857 if (WARN_ON_ONCE(error_code & PFERR_IMPLICIT_ACCESS)) > 5858 error_code &= ~PFERR_IMPLICIT_ACCESS; Nope, it shouldn't. PFERR_IMPLICIT_ACCESS is a synthetic, KVM-defined flag, and should never be in the error code passed to kvm_mmu_page_fault(). If the WARN fires, it means hardware (specifically, AMD CPUs for #NPF) has started using the bit for something, and that we need to update KVM to use a different bit. > > Continue passing '0' from the async #PF worker, as guest_memfd() and thus > > :s/guest_memfd()/guest_memfd/ ? I've been styling it as guest_memfd() to make it look like a syscall, e.g. like memfd_create(), when I'm talking about a file that was created by userspace, as opposed to GUEST_MEMFD when I'm talking about the ioctl() itself.