Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp3020661rdb; Fri, 22 Sep 2023 15:49:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHGoPyyB0gnBda9QJasIDuWVf5DMo0BZeaN6x/kco0wL2IF/UUZOvsoj27Ttus26LXR8dT0 X-Received: by 2002:a05:6358:930a:b0:143:7304:32b4 with SMTP id x10-20020a056358930a00b00143730432b4mr889721rwa.21.1695422982056; Fri, 22 Sep 2023 15:49:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695422982; cv=none; d=google.com; s=arc-20160816; b=WGTHFC876VaUIKAO++4j5hMNtCDjF1eRvV2gJcEknaMCc3pOm9l8z52flF17kz3Bj7 OMHCCldRNWAlMCVeM/qNSDFBnzyiKlHWTjv4n2SVsgsiDkpP3SafTlifIaL3JgOIxLLK fQgqOZvP5Hm5IY38RiMzMG76LrK3+xnvXgGleKsnzAfPVWOrq3Rj/2QXFjCPP80nT62D R69nqkoGVZ2sZvB3nww3H4PO8eUtwF9YQt35G8P6SdnsQYVguZrJ8raQ97jKapGxqptt 0SkaUcxox8TVjVZ+OU72XkDkLthumoKvRuQitfYsqLlSR8UfcfOyuWvPZo7o7f/O8NKD swqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=Q0oE+/MaiDFgsp6iziho8X2Tgq3nTZtQM1PapiHujnw=; fh=Gw6zT4ZBh0Dv1fRpn7gAKbzJcGu9in/CJQ0AGwnuEQI=; b=qV4/9TQHb/3tdpcKXU/sCIAVUaF4z3PjJWPoUxfKKfBeERZ6ctfFcuK6A6/eX4pAdk Lp7gK3rbJQietp7mZxkhJ9vQ7vDW3fzvwSJOs0j4mAuH8w8qDZKx41sHgirq1LH5iOgi ItOJdVtHef0HHcpMFWBu7IWR1kHLnvY0mbxx/uiarHLxs8YtWjTwbKw5FQWbs2T6Lmbp 450MQUkapU+UEcFW4ktm4tK6RBimwsTb9fTWgYtr6CRnQoDeQlO9wTLJxDF8UVD/MxCX gztdt9oPNC5MZVADPtOJsdV4OCgW3Comy7dx07PfogSQRkmAtsqitp8qvXxzcfKHboAK lxLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ZA4WLfBr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id cq18-20020a056a00331200b0068e486a14e1si4753470pfb.163.2023.09.22.15.49.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 15:49:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ZA4WLfBr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 389F880D9B13; Fri, 22 Sep 2023 09:36:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230132AbjIVQgK (ORCPT + 99 others); Fri, 22 Sep 2023 12:36:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229831AbjIVQgI (ORCPT ); Fri, 22 Sep 2023 12:36:08 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A780F194 for ; Fri, 22 Sep 2023 09:35:58 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-59f4bd6905aso502717b3.3 for ; Fri, 22 Sep 2023 09:35:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695400558; x=1696005358; 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=Q0oE+/MaiDFgsp6iziho8X2Tgq3nTZtQM1PapiHujnw=; b=ZA4WLfBrxv/ARJ+poYYBkLIG5/ddO3BfpztDs7YRHfdXPg8wKb+NZkfdtepfWpJc+O 54w0MPfn7qY0wRZKsIn9q9Uxiwptq904VDCJj0z3n/1aHFWwgT8wdlJoFzYq3BLhuA5n bMdgz3e7FuHTKdoN6EYIWfDiweJmo0Va7kq+H5o0nBwxfE42KhmbxKo6r2V0e96z4BaX cgHTZ7D/5XTQrOGhsJk1aHt7TsSXhxmaW6vNs5kCJ/9lccpAfpicyGlNWU0boTxS1v+T iJDhtBFHS9+e74oY3Eb5BY9hw9Lmk7dZxObw2gzxzYYBkbgSjNlH821Kk+6N/IozIGIh oMfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695400558; x=1696005358; 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=Q0oE+/MaiDFgsp6iziho8X2Tgq3nTZtQM1PapiHujnw=; b=JNhZjmak1upGhHkxJKqdzvqUgQX4CdokWE31CWh0u1t7YqbQaThXkV3uOTS1GjbPg1 GInpP0FAyHpo/Po+h3TslQ/U47/LnBzeocbzf0ulZgBzzp6uYfSebpcMprgevxM+9wnC 8b3QSCVic4ahQXKp6Pdkik2E6YmiIcM6wQiddMqLi3EN5XXQH31STGyITzNZSmXUMtX1 CSadR2ZD62a8fySjYI0GzeO5AicQ5C9ximLd2O8CeN6MI/JHw/XU1/2HR+MySoIb40nn QAmaHKAtbJe1CDbT7O4emTGutgJi1D40YwfAKpZkawdRD28ucInpvLFNRHCCqEtB3gkc 17yA== X-Gm-Message-State: AOJu0YyWNAfK0Dg/S4FaQgsPkH4YOleelM0YaIhQ4DBdtZ0haA8Oj/fR wmXMwRkZYxNXxbhsiTjQA2Yo/7FezaQ= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:b148:0:b0:59b:f3a2:cd79 with SMTP id p69-20020a81b148000000b0059bf3a2cd79mr3289ywh.8.1695400557678; Fri, 22 Sep 2023 09:35:57 -0700 (PDT) Date: Fri, 22 Sep 2023 09:35:55 -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: Xiaoyao Li Cc: 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 , Anish Moorthy , 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="us-ascii" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 fry.vger.email 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 (fry.vger.email [0.0.0.0]); Fri, 22 Sep 2023 09:36:10 -0700 (PDT) On Fri, Sep 22, 2023, Sean Christopherson wrote: > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 7c0e38752526..d13b646188e5 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -4184,6 +4184,16 @@ static long kvm_vcpu_ioctl(struct file *filp, > synchronize_rcu(); > put_pid(oldpid); > } > + > + /* > + * Reset the exit reason if the previous userspace exit was due > + * to a memory fault. Not all -EFAULT exits are annotated, and > + * so leaving exit_reason set to KVM_EXIT_MEMORY_FAULT could > + * result in feeding userspace stale information. > + */ > + if (vcpu->run->exit_reason == KVM_EXIT_MEMORY_FAULT) > + vcpu->run->exit_reason = KVM_EXIT_UNKNOWN Darn semicolons. Doesn't look like I botched anything else though. > + > r = kvm_arch_vcpu_ioctl_run(vcpu); > trace_kvm_userspace_exit(vcpu->run->exit_reason, r); > break; > > base-commit: 2358793cd9062b068ac25ac9c965c00d685eea92 > -- > 2.42.0.515.g380fc7ccd1-goog >