Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp766133lqs; Tue, 5 Mar 2024 16:26:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVfR7lLdlRHi8fGIjFY3Mtvy6p1SsQVlkocI9raxHff1LJWhT3Pc3x3Jr44vOd1JrotOb7vUFCFq2VPCeea5CJVvqv8cBwBcgDoQSPoGA== X-Google-Smtp-Source: AGHT+IEqXv2vttE5X+kaTK9jMBdtOCxeiTQql1BmFMz0fKEOcn/OAUiZe75R+Oasu56ZrbZ2e0L8 X-Received: by 2002:adf:f183:0:b0:33e:4ffa:dbee with SMTP id h3-20020adff183000000b0033e4ffadbeemr1281957wro.7.1709684775164; Tue, 05 Mar 2024 16:26:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709684775; cv=pass; d=google.com; s=arc-20160816; b=hC45THGK5szkdIlVyrKeH+LTNcHtrtCYwkQSBrvkYKERU0vMB9mp2SRDJNlgNJO6GS mZ5IAqLCa1PonIWibP7bRwE+zJy2WNhZEhRiD3H6+bHo284XOJiiT4WehM29qwQragAo vJyj2eKZbQeJRRoNaH4qJvYnzlwAeiusyN31RFPHYi0zk842ypL6hHicO8If2wk+p/Yh q2fxVCZgWEbeo99yoc8YN41q8233p00CI5vpZorChVloByMEZNKYYjiu22vEfQjILBD7 nxazdsAABYOTUmUBtt9CXCYllPpZTWLI6pcNNomsPEzGMHih9YiWCy/Wj+yvkg3EcZaf +Yrg== 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=9f6NA83OzYo58HbjFCzlBsiK2gdKmrkemt55OHdw4EM=; fh=HyHmCxNxCoZhTUlWnCKy525c9HjI8GGAJ5AOuNd0bdQ=; b=rhxJl69Z0Ah0kzIK6xIbkwrorJK/l/LKTDFUSvoHSZLh28nE1t2qaLLdwvENBdEDnE /B3HS88pjmef/mu3CTUl9lKcrIvxIfluPidGcyUUNDDIF6BZCKdxt8zmwaEjsLdnutZq EQ1Mz2RQGXw+1XqZFTzqVHENiUih16m/fge0tKB2N7SedZQJOBUKkJKq7gYHVrlPFGj0 BM9l+sw2G0kg5rMWKhZ8quKWGL9k5g9HWWIwkYLzBFrO5R6zxuufzbkFamVxm3lY+qen RFmbPaccaUuocELhhq5lgGS3G0Ov36PvY/cfFO9tB7at2tvjyNvmulQr52o1yj+P1Tit OCEw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=q6eOSqPL; 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-93167-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93167-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. [147.75.80.249]) by mx.google.com with ESMTPS id b8-20020a056402350800b00566a3ab4f15si5576893edd.39.2024.03.05.16.26.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 16:26:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93167-linux.lists.archive=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=@google.com header.s=20230601 header.b=q6eOSqPL; 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-93167-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93167-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 DF7851F26732 for ; Wed, 6 Mar 2024 00:26:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DDAD2101C4; Wed, 6 Mar 2024 00:25:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="q6eOSqPL" Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.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 B4CE8DF44 for ; Wed, 6 Mar 2024 00:25:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709684757; cv=none; b=UstV91JM/eG6FcCqqz2KYmVywGOLu8DdB9nRBTnv/QN/9cDQOVhWYopnPaGMpj/AMJrOtfpywvAffeRQIlrUN8z09+S7kP+kd1t2RP1iTe9qfbpVl9gY+WR16aycw0P52Lb98xFOLe8zJhj8l85JVlTT9fZcciIbfTFhl9n7qgM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709684757; c=relaxed/simple; bh=cOzX46HPtdjFrZDrmpp1FEEiEuyKrMsxVJ0ppoHR8yE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mM26ugfuxBODyB0Mh6LmL0cydn9pRhoWsXqfd42bJ4mpymIvmLt4L02LrTCk3oAU/Ar15oWZfcv+nB76XxhkQzEf4kfCuWZNbLXTX5sdRwyjFDSy4b03dKTqNgsZBX94Pju8JIHBY8abEFrbRfCPicXHUxoMd9T04ceteVHxVKc= 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=q6eOSqPL; arc=none smtp.client-ip=209.85.214.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-pl1-f202.google.com with SMTP id d9443c01a7336-1dccd2efdbfso62270075ad.2 for ; Tue, 05 Mar 2024 16:25:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709684755; x=1710289555; 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=9f6NA83OzYo58HbjFCzlBsiK2gdKmrkemt55OHdw4EM=; b=q6eOSqPLilYflk66Uy3hgvRicweV/WWinCVNQAd5C+ki6SnQRZ8RMBoYwa4PJa18zG 7C6we2TtBfXgUmSgZ0COYeVZa7X1zc7DpeGMfH97mVjCgQjK8xoOprfGfHMdATBywrQE h8WzDHHM6UWpQ0PM/Tw15j3mM5a1dr+rFKFO/Egfmwu/StqHYj7laTtmW4HV3uxED3lE boWuEylNO1IFv+nsILdlZpPHYIl9n3qzxxOrYe5wHQLhYRC+37es/j5R1Ja1WtuLTAml 5wtQ4ukWqyrc/6GLigQEMLg69eKARkEFpFwVrJLd0IWphW4jFKkjpS76tfyyRmINqfTI OEYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709684755; x=1710289555; 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=9f6NA83OzYo58HbjFCzlBsiK2gdKmrkemt55OHdw4EM=; b=qcVh9B1V+GfEuiL/pBN57Ag3BCPAaHFy7AfeiV+4Ni/pX5Y4gpMbh346u2E56LhGSt XMOa4VDM+nVnnakSbscDZQmAzZuW+SBaDQpuUMUanQ+G4Md97FgZU5uK2U8nzVl8cbg4 dyShKieJfoIefvvNfmDodHMSrmHqqDMhmrAHBsGVjI/qt3VBYNsDWiIXPJB4yrynBY98 PTYZnL0yV3AqQid4qvInC6HXONcyhXe2ckeJsGo4tDwOI4m+cTAFAi+mdl/Mt30FutVM l0LREAvErFb3232xMEwDXA/T9s1ByY1Qt1rLLLNstEp9RusaJBA2EI7QyrDeZudMVPZ4 zFyA== X-Forwarded-Encrypted: i=1; AJvYcCW1lEhj0sz2HBSZMrdOP1w1lXJPiPrg0vK1HbSW3EfUjYRBoZ+6l7Rl0gO5QcmcUV3Lr4AhuBq6TZYW6X73rhX3swTVUbXv7HgHSzlF X-Gm-Message-State: AOJu0YycKflit03YJbZPkCErymnIoFHPsb2xY7rRkW7kmhXFAj4Rwy4r bzEpkBxLxMoMmjk5R9iC6lp0brkQNOjApjzLqPMb4qJlMra9pDCBO5tO4MjAh0HAFXMCEk6F/Xz S/A== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:e544:b0:1dc:9220:5e7 with SMTP id n4-20020a170902e54400b001dc922005e7mr26207plf.0.1709684754732; Tue, 05 Mar 2024 16:25:54 -0800 (PST) Date: Tue, 5 Mar 2024 16:25:53 -0800 In-Reply-To: <420cf8e8-88de-40b1-91a3-6660f7568494@intel.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-9-seanjc@google.com> <2237d6b1-1c90-4acd-99e9-f051556dd6ac@intel.com> <05449435-008c-4d51-b21f-03df1fa58e77@intel.com> <420cf8e8-88de-40b1-91a3-6660f7568494@intel.com> Message-ID: Subject: Re: [PATCH 08/16] KVM: x86/mmu: WARN and skip MMIO cache on private, reserved page faults From: Sean Christopherson To: Kai Huang 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 Wed, Mar 06, 2024, Kai Huang wrote: > On 5/03/2024 4:51 am, Sean Christopherson wrote: > > In other words, KVM_EXIT_MEMORY_FAULT essentially communicates to userspace that > > (a) userspace can likely fix whatever badness triggered the -EFAULT, and (b) that > > KVM is in a state where fixing the underlying problem and resuming the guest is > > safe, e.g. won't corrupt the guest (because KVM is in a half-baked state). > > > > Sure. One small issue might be that, in a later code check, we actually > return KVM_EXIT_MEMORY_FAULT when private fault hits RET_PF_EMULATION -- see > your patch: > > [PATCH 01/16] KVM: x86/mmu: Exit to userspace with -EFAULT if private fault > hits emulation > > So here if we just return -EFAULT w/o reporting KVM_EXIT_MEMORY_FAULT when > private+reserved is hit, it seems there's a little bit inconsistency here. It's intentionally inconsistent. -EFAULT without KVM_EXIT_MEMORY_FAULT is essentially KVM saying "something bad happened, and it can't be fixed", whereas exiting with KVM_EXIT_MEMORY_FAULT says "there's an issue, but you may be able to resolve it". The ABI is a bit messy, e.g. in some ways it would be cleaner if KVM returned '0'. But doing that in a backwards compatible way would have required a rather ugly opt-in, and it would also make it more tedious to extend KVM_EXIT_MEMORY_FAULT, e.g. pairing it with -EHWPOISON didn't require any new flags.