Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp8501988rwp; Wed, 19 Jul 2023 10:40:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlFELdctTM8NC9w/6wqxK64CHcWd5NhIsXg5iUUY+pQR8hOt9kMEA8sn/TrIiRplADo5er4r X-Received: by 2002:a17:906:779a:b0:997:e9a3:9c4f with SMTP id s26-20020a170906779a00b00997e9a39c4fmr3506400ejm.30.1689788437040; Wed, 19 Jul 2023 10:40:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689788437; cv=none; d=google.com; s=arc-20160816; b=ldSwkvDl9zbLYts3vAl5jCNg596xttfK94xghMyMX36shdtNRXCvgZLWIxSl0+XfTi kk38LST1KPlqPkpom8ofTzAv0KbLWt2f/UrADE1n2+rfidF8S0Z4YZxBqTYZGzKtbZx7 k7EGK9fhNi85OZcuh8lS4mnYzMZxwOOWVCxYG3AayqK5L1IeIeHQKI77n+g4uaowXu2G HiR9CFQhvIzDwnogsLxetZAb9hRlH12NV5njIcDdEMhiaJHN/nkHSic4tmAJZ8rIP0md 1KSMNlIJvOEbibYejR007I7QUfRZtbIOdt07+8WjCodzFiPsNVVj8mCdGHbtVW8ad2fW VxkQ== 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:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=muf27eIntjXr3Sa3gdcQLPN4y9AYfVWt2TffDnLSMcw=; fh=Z2Sh2b/nD63leKfjj34RmZ+J+UDf5iGo+3k3SLalPcA=; b=xH6MZLiW3t5bIvBbL81taP37P0+aiBP8AJSn/jCHsdH504u3C7daZ5GBfUgJe6u7ym Y2Zd4ep/O3XLlEjzgSWnXTdP/BOGPAXD5kyG+Vf8TVk8yNG6NjrxvKMv+ASwTgW21en0 DX1sLloVFH9zkKzEdvpMXUocdxOQt0yZwAc+Q347dsHy9CvpeSQGMcDhhn7lIkFOQebD B7Dt0mzfFcITV4BQioWUzZOoB0lBT5Tg6R1SJ/jcfX1puIw6g1a6R2dsddb1CIghrfs8 Vj3tss1pbULn3Kek2lyS0ZsE6/tKxM7bBYNlrU83HRv/eVCZC4GlYhb6fE5xKk5OrMx5 /jtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=yA9Vox81; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t18-20020a170906a11200b00992d6fa3b33si2859887ejy.440.2023.07.19.10.40.12; Wed, 19 Jul 2023 10:40:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=yA9Vox81; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231246AbjGSRWM (ORCPT + 99 others); Wed, 19 Jul 2023 13:22:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231250AbjGSRWK (ORCPT ); Wed, 19 Jul 2023 13:22:10 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B766197 for ; Wed, 19 Jul 2023 10:22:08 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-991ef0b464cso230299466b.0 for ; Wed, 19 Jul 2023 10:22:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689787326; x=1692379326; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=muf27eIntjXr3Sa3gdcQLPN4y9AYfVWt2TffDnLSMcw=; b=yA9Vox816zD+aJ/FVd+gHS1eUUrpLebV0UPRWoTOQXRhwbDjiEzKfZKLt7ZPO+mtvH SaibLGPqQv8DRVnknibkmwFWbPPfcXmr6c+ujgDGBFuCW/F/BitDoK4IVXsvCkVTbM2a UUXFrIHyb9EtmF0G0jSo223YyW0H9eb4QyBBeSzBXy3UqItMc2tyGgaUGUFrdupt+8A5 dLZgmELLzzoUW2SKSL+4MBdgHsq0BaZC4v7p3QuLBtrY+JwzHEa0w4RaSfJgn6bTpTvs oKq8cg7sWg40yA0HzTTcfPzlRvV46kkywbP49vwd3eHSPLgVvqkoTlu6Tp2eaYz6GzrZ sQlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689787326; x=1692379326; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=muf27eIntjXr3Sa3gdcQLPN4y9AYfVWt2TffDnLSMcw=; b=eMxmH013qQeX/3H0jRTfZ49ApPhfy3b0UoAvc82+gomTOVWS9gYs9EOwEGUsTGmzEQ HEQDRGsG9af3qdvHtc+3/cAeh3yeesjACBeKsv6f3endL4ZI/Jgw/FEf7zL/iWYHAcDK 72dn+mVb8mMvJ07AEtVhBqBZwbexnwQ+1hEHjNfJTAFkPeMgNIh8pZ7AuRKIyNnmq83h /VXAqbecgA2vCLYkY6E+KSR+n+WiNGHaOijFihY5osZWvFV5vEwqW780oEJXnXnryeBf JrMz+8qWq1usMcyuke8e23LLVnXMzqkzvmvtLD0jBnzf/nBgeo9EraATxz4RpQ1g8tOr 8T8w== X-Gm-Message-State: ABy/qLaTlCavrH8658cvEBAzTsAUILMvsd5xHj2VHlpzYACEd/QIBMhJ 7cD1Bp6sqHdiEqDbce+WdEtEAfeWet54oWoh4J60jA== X-Received: by 2002:a17:906:292:b0:97e:17cc:cc95 with SMTP id 18-20020a170906029200b0097e17cccc95mr3045374ejf.36.1689787326540; Wed, 19 Jul 2023 10:22:06 -0700 (PDT) MIME-Version: 1.0 References: <20230718234512.1690985-1-seanjc@google.com> <20230718234512.1690985-13-seanjc@google.com> In-Reply-To: <20230718234512.1690985-13-seanjc@google.com> From: Vishal Annapurve Date: Wed, 19 Jul 2023 10:21:55 -0700 Message-ID: Subject: Re: [RFC PATCH v11 12/29] KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory To: Sean Christopherson Cc: Paolo Bonzini , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Matthew Wilcox (Oracle)" , Andrew Morton , Paul Moore , James Morris , "Serge E. Hallyn" , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Chao Peng , Fuad Tabba , Jarkko Sakkinen , Yu Zhang , Ackerley Tng , Maciej Szmigiero , Vlastimil Babka , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_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 On Tue, Jul 18, 2023 at 4:49=E2=80=AFPM Sean Christopherson wrote: > ... > +static int kvm_gmem_error_page(struct address_space *mapping, struct pag= e *page) > +{ > + struct list_head *gmem_list =3D &mapping->private_list; > + struct kvm_memory_slot *slot; > + struct kvm_gmem *gmem; > + unsigned long index; > + pgoff_t start, end; > + gfn_t gfn; > + > + filemap_invalidate_lock_shared(mapping); > + > + start =3D page->index; > + end =3D start + thp_nr_pages(page); > + > + list_for_each_entry(gmem, gmem_list, entry) { > + xa_for_each_range(&gmem->bindings, index, slot, start, en= d - 1) { > + for (gfn =3D start; gfn < end; gfn++) { > + if (WARN_ON_ONCE(gfn < slot->base_gfn || > + gfn >=3D slot->base_gfn += slot->npages)) > + continue; > + > + /* > + * FIXME: Tell userspace that the *privat= e* > + * memory encountered an error. > + */ > + send_sig_mceerr(BUS_MCEERR_AR, > + (void __user *)gfn_to_hva= _memslot(slot, gfn), > + PAGE_SHIFT, current); Does it make sense to replicate what happens with MCE handling on tmpfs backed guest memory: 1) Unmap gpa from guest 2) On the next guest EPT fault, exit to userspace to handle/log the mce error for the gpa. IIUC, such MCEs could be asynchronous and "current" might not always be the intended recipient of this signal. > + } > + } > + } > + > + filemap_invalidate_unlock_shared(mapping); > + > + return 0; > +} > +