Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp602269lqi; Thu, 7 Mar 2024 06:36:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUFINtDJJmPN5o1EzOXeZDWkjQvHwMCNrpo1JBsNbgBheYcvfd1A46mTVr3xi+yafFn9ywwixNRcb2RvncHgmINvg+XRUMnZtMC3wqwbw== X-Google-Smtp-Source: AGHT+IGkr8clkMDmp/j+P0nTV7hft7H7nWzi4iHxFL9FQ9irT5fx/L0a7xrJ7ZXonhkrfdx3Nv3r X-Received: by 2002:a50:8e5b:0:b0:568:2505:93b4 with SMTP id 27-20020a508e5b000000b00568250593b4mr208440edx.6.1709822195060; Thu, 07 Mar 2024 06:36:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709822195; cv=pass; d=google.com; s=arc-20160816; b=X2RbNEFQqwsNgk7V/QDdEyT+7KJC2kUfyWSYZoZfnAh4wDbBKKx/DYC1twWtKvY3Qb 4LSiVj6WB3qJY80NnRXpBDj/B7K+lxKr6xAXQYb3KGcw6lz5KBsV1HfZh1SCYOKjav9O rNAn9WRv2ql9ycNaHdjHNfmvf2Yu34CZ6TbBkV6NXpDNFsUvYMioiNrpoYTiAIyowihf 10J+knPi3y0qYaJ/8bBwgsKOjttLc33AHhm+UTwiKovumTucXGIA6/7JJ6wovnFhmB01 yq0NStOK7Wbk3OygA1KWiB3zWGB9YVuV3d9BOpWe+JQz0lN4FZwKrEm8Wj/p/9HY3R+y syyQ== 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=uQkndU5MaQMQimAlXbJ2bKIU8av7qyfvd42xkrItWQQ=; fh=ikA20+M34NR+Tze01JYLxJNz0ssUJ0SlEhaGZeczfDY=; b=S/TP2hoQLhrIcGwOFSYZc0xJNPKKWbC7A8PJ76CvRc/LWiAM/lbyCV6S3cQf8Quvbn HWlOS/yOYBEjw07qaUC2/WWAsCtjJy7tjHcpuoGb3nJKpQqs/Bd7l8E9FvZWpUVlConR yeYqRe0fzdOcsJ9yjydGgeGxkNfc2Izb84woDph20fd5YYWhpt1G5H16nrZu+d/sN27B ShjV9Zzc1EdWbYG0GAFp56tfg30lFXvEawLlnzK18ZqAkzFdUj/Gi26/GOountazufl1 XmPUMPPUcKjr5uqiUuLNXr0DdXgkksnPpqfYDpOtgm2v/jYqVzvvEjZB2ot9xbFsqyJx A82g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KOwv1gkT; 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-95743-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95743-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 j2-20020a50ed02000000b005664ee61abbsi6995415eds.610.2024.03.07.06.36.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 06:36:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95743-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=KOwv1gkT; 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-95743-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95743-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 C352A1F268A5 for ; Thu, 7 Mar 2024 14:36:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A7EC1EB39; Thu, 7 Mar 2024 14:36:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KOwv1gkT" 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 DCEBD1C6B2 for ; Thu, 7 Mar 2024 14:36:09 +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=1709822171; cv=none; b=KUtLUGPO7oPtIScDi9sxy4Wu1EE+W2KmOUsHzTaBJ3+z4L5gnHOxtDd+HdRgsO6Ii6Xk4NxO/eeTTHGlJ0Q9EYjckAdv1NPq77NDpEohLERSDBPcNZmiDDz4E72Em7dyY1WhVH2YscX1ccJ/FkXe6HNv+mrumyD0FDR9GvOLdpY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709822171; c=relaxed/simple; bh=5c2pdnlbWCYsX5AL6tAQ6PuzfWITspmp5cYuOF4KTUg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=uTwbH2IGw69lnMRgpTGXCiyseiqqOs/mn+zO+2Kdq25Kx8UsPCOjOZ8MNDJ8D5PDjiXtyRztfuMDQrBy6OwNcftvoCiX8SmTWskU3M/mqumIpbRPZEsg997FJ6Dn7xA8kMjq7XTseuV5J53jOO477cnOW+lKcb7aMw+RVEWipZI= 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=KOwv1gkT; 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-608ac8c5781so17301897b3.3 for ; Thu, 07 Mar 2024 06:36:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709822169; x=1710426969; 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=uQkndU5MaQMQimAlXbJ2bKIU8av7qyfvd42xkrItWQQ=; b=KOwv1gkT34HkiFNiGgwW3I7Siwb8jdEV/eEP/tTXJP9R1EhMpAAa5x24qFnk+joyOQ NM7Nc68HZRj6f6PTA2ZE6/M5qQ+2/6r4ULBsTxfVopx/xTGl3L1Os4DXY3S1atmlVWyP 2A5X+iYOW4dtgH7TtSnb6cImEhYr9X4abrFmVzITP6O3Pw+h320s8jJa2qs0JakH1tqU qd/DW9Y26PEts76gL5pwfYC21frDGxffWYqvE4jQ6JgVvC76SRBh2mNGqgXGkpfLbC8J xaeMCJcEUyxGuZtwnsm4OAO7ejY+jlAjUiTauthyEVzmirSCVKlXF3c+p1Pl8nIOocnC 2LtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709822169; x=1710426969; 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=uQkndU5MaQMQimAlXbJ2bKIU8av7qyfvd42xkrItWQQ=; b=gY3SM0kIFKSE6GRT6mch3In/qoYN+1A1z/MimH5gyXNC3Pt8WoJ3v+SYr22BQhlF81 PhRF+Gn/Q5rIPsnKMTa/qSpx2ukcbIOOuDxbUpEJ+cwGWr3kj/PlO6zRths5gfuIa5Ht eA2SRqgaioVS0hKRX6F6pvaPliQTKKKA3Dw6QRZYXA4KAiUBfpNmkVPzjnvwqZII0WuM nxrRuchj7l84MyrYUjHFq56jzHI/L/M+V0SLHNplAHhMn5OpD9Qxwr8Kco5R9/k/k7/X T1jfst+pbQMpoecwf9Y8v9GCWfF0+e1UWztfCdOrTPU+/5dQoJGgrt0Sd93a66yTCRXc dhDw== X-Forwarded-Encrypted: i=1; AJvYcCWTtAwvctnqH11ACrcRJSReaeJeP0lxMsG8PdMyuJTEWpH+WvF8L6remK5VVbXTuh85YTU9tBf8n+sAkiWYVruSlqhQZHzFbiNdAn7k X-Gm-Message-State: AOJu0YwN9WX4rcj7ceFv3R9k//yOc3/HvxXQ0+LCXk64f5Wp8AgK3hqD /9fMsn0Dg/4QKK6/+CJfArVrRG5lrZ9rqdtM3X8ZvXqbQlKy9TYV3LoIEN+0omarDi2304R7afl 1Sg== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:18c7:b0:dcc:6065:2b3d with SMTP id ck7-20020a05690218c700b00dcc60652b3dmr4413088ybb.8.1709822168860; Thu, 07 Mar 2024 06:36:08 -0800 (PST) Date: Thu, 7 Mar 2024 06:36:07 -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: <20240228024147.41573-1-seanjc@google.com> <20240228024147.41573-6-seanjc@google.com> Message-ID: Subject: Re: [PATCH 05/16] KVM: x86/mmu: Use synthetic page fault error code to indicate private faults From: Sean Christopherson To: Xu Yilun 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 Thu, Mar 07, 2024, Xu Yilun wrote: > On Wed, Mar 06, 2024 at 06:45:30AM -0800, Sean Christopherson wrote: > > can be switched between private and shared, e.g. will return false for > > kvm_arch_has_private_mem(). > > > > And KVM _can't_ sanely use private/shared memslots for SEV(-ES), because it's > > impossible to intercept implicit conversions by the guest, i.e. KVM can't prevent > > the guest from encrypting a page that KVM thinks is private, and vice versa. > > Is it because there is no #NPF for RMP violation? Yep, there is no RMP, thus no way for the host to express its view of shared vs. private to hardware. As a result, KVM can't block conversions, and the given state of a page is completely unkown at any given time. E.g. when memory is reclaimed from an SEV(-ES) guest, KVM has to assume that the page is encrypted and thus needs to be flushed (see sev_guest_memory_reclaimed()).