From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 117E5E92FC9 for ; Thu, 5 Oct 2023 22:46:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231706AbjJEWqc (ORCPT ); Thu, 5 Oct 2023 18:46:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230249AbjJEWqb (ORCPT ); Thu, 5 Oct 2023 18:46:31 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D440EDB for ; Thu, 5 Oct 2023 15:46:29 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id 98e67ed59e1d1-279353904a9so1368992a91.3 for ; Thu, 05 Oct 2023 15:46:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696545989; x=1697150789; 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=BFNKMdFnPveldc0HQ7aZGfenM2ZrJbvkhgfmrxqt94M=; b=b2ZAAo2RLBA8EGZPw55N+wyoEcba8G77IVJ8ZBcyQp2Dmi36Sn8Py4VOOv/A/7DA8B X4ZrjM15SD3XxzmLK4uTG9GIdFZWKGk0W2mKzCFxX+GyIJn1sastwlYLv6AJa9AwdlCh +t7uFiqtdMObMKKyShosdrvJESkXJBlxV5OUTyVtRbCHGPjPwtciJpxgqLILT4ms5hhm kCUXSEOnrq425/BV/1K4ftRZ/L9CycF7lKGYDceB0+JaNHJpy3I1LJG3GqfPoX55ilJE WibKy2ybISvuBuw4xrbycnIXVQnr9LCBc/E8+l5DsjgDZsfq+e1jGOOZJe7wm00Rnk/M 9i5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696545989; x=1697150789; 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=BFNKMdFnPveldc0HQ7aZGfenM2ZrJbvkhgfmrxqt94M=; b=bpsMinBOJmCEAsKP/baRJwzdQzEhpRqzCOe1wsZbvd/h02sY0cnjtLP+nej4VuA13t xSWHOsPaWYJRU/K5uzeAg92lyEz+6ePEsg2oHuPQ895c7m5eYO7+0faewoiY5VmjMw/n 3o4baUUDdzl8gMQ4T712mB558Jp2/GX0kq91xXyGDGohiL8T/o1pz4WES028BfrBZhJF klJkTn/XsCJgWXlsT9lPohkGOXaDvnSKg93kFxZyWSrzGWQM0aO+i+iT9TOzT7hNqCqw /QAjIOWR9MaWScJp5yjfCzopc7kEgPKWPnFaNg5SV2fV+ISsjwmB3hmc3JbXypesBF7N a4nQ== X-Gm-Message-State: AOJu0YzL13U9dlGzu7Up0ZkQAono5kg4cqey+I3+E2CeqNO1v1MxYCVS gkeTY+Tjr8XQjAnS+5jq1gIvvMeQUWM= X-Google-Smtp-Source: AGHT+IEtahwBg2Zwge0uEd3Ui7DNj7uWo5yXZrXRWofh6Qbm+2xT8gySHKj0YTx2KOHMFuyEUr32wAYCdkY= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90b:e06:b0:279:9aa1:402c with SMTP id ge6-20020a17090b0e0600b002799aa1402cmr104744pjb.7.1696545989346; Thu, 05 Oct 2023 15:46:29 -0700 (PDT) Date: Thu, 5 Oct 2023 15:46:27 -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 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Thu, Oct 05, 2023, Anish Moorthy wrote: > On Tue, Oct 3, 2023 at 4:46=E2=80=AFPM Sean Christopherson wrote: > > > > The only way a KVM_EXIT_MEMORY_FAULT that actually reaches userspace co= uld be > > "unreliable" is if something other than a memory_fault exit clobbered t= he union, > > but didn't signal its KVM_EXIT_* reason. And that would be an egregiou= s bug that > > isn't unique to KVM_EXIT_MEMORY_FAULT, i.e. the same data corruption wo= uld affect > > each and every other KVM_EXIT_* reason. >=20 > Keep in mind the case where an "unreliable" annotation sets up a > KVM_EXIT_MEMORY_FAULT, KVM_RUN ends up continuing, then something > unrelated comes up and causes KVM_RUN to EFAULT. Although this at > least is a case of "outdated" information rather than blatant > corruption. Drat, I managed to forget about that. > IIRC the last time this came up we said that there's minimal harm in > userspace acting on the outdated info, but it seems like another good > argument for just restricting the annotations to paths we know are > reliable. What if the second EFAULT above is fatal (as I understand > all are today) and sets up subsequent KVM_RUNs to crash and burn > somehow? Seems like that'd be a safety issue. For your series, let's omit=20 KVM: Annotate -EFAULTs from kvm_vcpu_read/write_guest_page and just fill memory_fault for the page fault paths. That will be easier t= o document too since we can simply say that if the exit reason is KVM_EXIT_ME= MORY_FAULT, then run->memory_fault is valid and fresh. Adding a flag or whatever to mark the data as trustworthy would be the alte= rnative, but that's effectively adding ABI that says "KVM is buggy, sorry". My dream of having KVM always return useful information for -EFAULT will ha= ve to wait for another day.