Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2280595rdb; Tue, 3 Oct 2023 16:46:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFzAIWpox1mXfKEsybDdDuzasdsbp0j6N+hvF3O5s8QNd11v8paUcNhnj7VkjOtGnUebTDV X-Received: by 2002:a17:902:f688:b0:1c6:3228:c2ca with SMTP id l8-20020a170902f68800b001c63228c2camr1259545plg.29.1696376798303; Tue, 03 Oct 2023 16:46:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696376798; cv=none; d=google.com; s=arc-20160816; b=H6rzR8EelJgn4UYKmZe9SbSs+wAKwe0iNUbCR+TmVJ0WJmX9x+WIu7R+BzJzrpuWLO gRwHXEzTwKMuyYmDTVkTX/oeLcncqEi9xVgxD0C4SBG2qOV6NErBU9l0v7k0FKDma8cX pHl5bNDc6IVcgB2AocD7G04K1fA/z/VGNV6ozETO4I5MgKjdvJNoKjk8rL7qTxxO36+D P080fLqQqZsAQGGzuTZdpCN7siCyW1Xi+JaqA3L5Q057WuwlHMWoCwce7FsQEfEUKpi2 TUYPiZRp9IgEb85vS7P/JXd3jr89oSRGUpdzF+QE4WTE2Wx0zcDTtez3dPomlk6PLtQ3 C3yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:from:subject :message-id:references:mime-version:in-reply-to:date:dkim-signature; bh=gaHRh+iyoB6/OttqFX2Q86pGvl0bhGVCVyqFTvtoGcw=; fh=11mZAwqBLoRZhobFeLsAeLWv09MNZGexV29Cv67kzGg=; b=xYki41QLPV3t34YTGKClufQhMgcqli9cCOtOTGMYwpmnkJwjO8FPAYmSmfAhEHfnMX aQoeghFhcGALNKWFr7M7nJndL1PAI4hOe8vzrVSJil8msF1Glr0zE7Zw/iqJG3RxTYtI RBi3/pXKXpBOri1jfPsKFD/87mHq1nnDRAaaxZ1IgXeU9OenuW0DsTaKWVrROoZgBjGi LofRZceBAXmQY2Qqp01TRmwggxthgt6FVobTYWMaBlf219+u4wHBzrv9M8qb2EeE/9y4 5vV9XxwK6uxwFFVsz83e4Ux95onI/CYka9YvfDrOT+mZ+b+hfevS+Bo9M5F5SerfRTa5 D9xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="zeSJ/jk8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id q7-20020a170902a3c700b001b9d0ad0d40si2358401plb.128.2023.10.03.16.46.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:46:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="zeSJ/jk8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 491378020487; Tue, 3 Oct 2023 16:46:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237474AbjJCXqc (ORCPT + 99 others); Tue, 3 Oct 2023 19:46:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237659AbjJCXqb (ORCPT ); Tue, 3 Oct 2023 19:46:31 -0400 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 898D990 for ; Tue, 3 Oct 2023 16:46:28 -0700 (PDT) Received: by mail-pj1-x1049.google.com with SMTP id 98e67ed59e1d1-27911ce6206so1316547a91.0 for ; Tue, 03 Oct 2023 16:46:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696376788; x=1696981588; 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=gaHRh+iyoB6/OttqFX2Q86pGvl0bhGVCVyqFTvtoGcw=; b=zeSJ/jk87sZLLQE3qHWB5Onl/GnOQfZiDOraNhrrCtssbqZAA1MS1ukg7TKv596X2v r9dBnSAFnEYzXw1YhYt+pLvoCa0omHCo/CDL9PWdgws7U+/nf6DLhti/pVo6DBZisBJq 6pAtIkBTtcSU4yGLlSew038ojTMHlLqRqzPj6wzUoO1WJvYJlWDQ2/x4Mm8CUAUYD6k9 6yOdRPNNieeXwa2j8xrRZUw1YvmPYXilCWLgoMQ497c7mVsWMp7f9rPgHAc/OBm47B3g YAmu8QrG9A2PvbfMF94kbzWWt2mpHDgC5yMHMnSxYTb+gReZXWk51QzfPLS9JefE8ZcU Zvdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376788; x=1696981588; 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=gaHRh+iyoB6/OttqFX2Q86pGvl0bhGVCVyqFTvtoGcw=; b=VEXiArZvUBN8wLfsZA54j0o2pSXtzvU0EGmZWwP1lS/8yoI+pu/F5HJN+EEq4AdUS9 GnsJUfrqA5vH6TaJSf9Urf5EIkqj/g90AEjzqHODpGKHzbp4BuQzCECFIUqNUwQuyWhE cHC6eXsfq1EF5Xb7R1KVFYwL3MArsD2fjZfg+XSeQaRsbJ6I+avLelrCpVn64Micu3p5 +QOcyw83Ex3ZEjLI1AASxCpLFybmhAotLVgNd/468HaY7PPOvb2OE1aGvHKqqBBU0XqW eYXB3ok4EF3RfY/SSTrLZz/L+bJIfNp/JIJrdpTHpQ5uS5xtvGmQiIdT7o8maCloc2ft 5BFg== X-Gm-Message-State: AOJu0Yy0J5E4KyTp9RUI5E8WVb2JNB/otTL1Xh4AxnpCtAmMOo8Nuh0G B62Nf7dadU5wpk4Zht8xQkerbE+PUtc= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90a:8186:b0:274:6af0:d75b with SMTP id e6-20020a17090a818600b002746af0d75bmr12051pjn.7.1696376787828; Tue, 03 Oct 2023 16:46:27 -0700 (PDT) Date: Tue, 3 Oct 2023 16:46:26 -0700 In-Reply-To: Mime-Version: 1.0 References: <20230914015531.1419405-1-seanjc@google.com> <20230914015531.1419405-8-seanjc@google.com> <117db856-9aec-e91c-b1d4-db2b90ae563d@intel.com> Message-ID: Subject: Re: [RFC PATCH v12 07/33] KVM: Add KVM_EXIT_MEMORY_FAULT exit to report faults to userspace From: Sean Christopherson To: Anish Moorthy Cc: Xiaoyao Li , Paolo Bonzini , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , kvm@vger.kernel.org, kvmarm@lists.linux.dev, kvm-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Chao Peng , Fuad Tabba , Jarkko Sakkinen , Yu Zhang , Isaku Yamahata , Xu Yilun , Vlastimil Babka , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 16:46:35 -0700 (PDT) On Tue, Oct 03, 2023, Anish Moorthy wrote: > On Mon, Oct 2, 2023 at 6:43=E2=80=AFPM Sean Christopherson wrote: > > > > > - I should go drop the patches annotating kvm_vcpu_read/write_page > > > from my series > > > > Hold up on that. I'd prefer to keep them as there's still value in giv= ing userspace > > debug information. All I'm proposing is that we would firmly state in = the > > documentation that those paths must be treated as informational-only. >=20 > Userspace would then need to know whether annotations were performed > from reliable/unreliable paths though, right? That'd imply another > flag bit beyond the current R/W/E bits. No, what's missing is a guarantee in KVM that every attempt to exit will ac= tually make it to userspace. E.g. if a different exit, including another memory_f= ault exit, clobbers an attempt to exit, the "unreliable" annotation will never b= e seen by userspace. The only way a KVM_EXIT_MEMORY_FAULT that actually reaches userspace could = be "unreliable" is if something other than a memory_fault exit clobbered the u= nion, but didn't signal its KVM_EXIT_* reason. And that would be an egregious bu= g that isn't unique to KVM_EXIT_MEMORY_FAULT, i.e. the same data corruption would = affect each and every other KVM_EXIT_* reason. The "informational only" part is that userspace can't develop features that *require* KVM to exit. > > > - The helper function [a] for filling the memory_fault field > > > (downgraded back into the current union) can drop the "has the field > > > already been filled?" check/WARN. > > > > That would need to be dropped regardless because it's user-triggered (s= adly). >=20 > Well the current v5 of the series uses a non-userspace visible canary- > it seems like there'd still be value in that if we were to keep the > annotations in potentially unreliable spots. Although perhaps that > test failure you noticed [1] is a good counter-argument, since it > shows a known case where a current flow does multiple writes to the > memory_fault member. The problem is that anything but a WARN will go unnoticed, and we can't hav= e any WARNs that are user-triggerable, at least not in upstream. Internally, we = can and probably should add a canary, and an aggressive one at that, but I can'= t think of a sane way to add a canary in upstream while avoiding the known offender= s. :-( > [1] https://lore.kernel.org/all/202309141107.30863e9d-oliver.sang@intel.c= om >=20 > > Anyways, don't do anything just yet. >=20 > :salutes: LOL