Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2700115rwr; Fri, 21 Apr 2023 12:39:33 -0700 (PDT) X-Google-Smtp-Source: AKy350b57rKwOkw/EBJjGNet2U6yNLqJzZlIAy4t1LdSAgB2ls3YRcb5tNXp6KCiCsSATCkUGZw/ X-Received: by 2002:a05:6a20:8e19:b0:d9:a977:fae with SMTP id y25-20020a056a208e1900b000d9a9770faemr7394674pzj.3.1682105972811; Fri, 21 Apr 2023 12:39:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682105972; cv=none; d=google.com; s=arc-20160816; b=bCSzGEvH+2qV/RYsn1jg+PiaNNt1s/HEeP2pFJD2wPh7RZ8EOVUPeQfv9PVKPzkVgt bKatGIT2WCsPOsGSyiP7HNSwYGbGqgdpcS0ijTF9ZcLQsQj4XY+x2eABSlw3KScXaLeR MqfimxwDGZ5H3R0XkN1z5Qig7SlBcTwpVFR/r0IvjO/2bXUY+hWFsw8+Gq26gbNUJyEO AymilJKIq/wo+/dqgx+x75DvJhC8+9/ESDT2Odldq6yvj9/oUKglzYRNnNQ/JDmIqIz5 dG5LfFgEFl5hznpotLrVSlv55J6xGedj9AKL8f87erw4TT0xUI5tqiC6dn3YF2rZuWcE Vvrw== 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=lvkLA+a8YoW/wuOsjaIxJzuPVSb1YjjMK/JpWWUYlMo=; b=LaPX9LYPj/LdxI5BTnL2PjomH+7zkTDhHX1EIK/OwLn9mc1n9KTxlsVLfnAfGB6j8Y dpUCDsr//FdAOGyfp6wpTIGmrV+0k93/gJmdScP55oKVSVb07oUr49F16LfwVDERs5YG TkQevyg1f1JlNZgpeA2qmIZZ3FX6IIWyhzdAIkb/J425v7a8IU5gB2LwOkTRaE0Lkssv wXV4MwUJbItKxdFtO+HY4m0vBDtxd6+r0I2/9tvdr5n+Solu4qNg/81HNwLLYXumx9e0 5PzKRIFHPS2ausd+5RzKiHbpXMF/paVCuPO7LLVaU+FJ+QkyZL8H1oyaGiH1rKUtqVdl wHdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=Z1mYNDZ6; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i2-20020a654842000000b00520e8ddcb67si4983431pgs.195.2023.04.21.12.39.21; Fri, 21 Apr 2023 12:39:32 -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=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=Z1mYNDZ6; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229601AbjDUTY4 (ORCPT + 99 others); Fri, 21 Apr 2023 15:24:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233522AbjDUTYy (ORCPT ); Fri, 21 Apr 2023 15:24:54 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 416492682 for ; Fri, 21 Apr 2023 12:24:53 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1a50cb65c92so22431955ad.0 for ; Fri, 21 Apr 2023 12:24:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1682105092; x=1684697092; 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=lvkLA+a8YoW/wuOsjaIxJzuPVSb1YjjMK/JpWWUYlMo=; b=Z1mYNDZ6AkudtVnrT3n5V/eEIts8OddUDSW9KLn74LxIddwBxxMBvHvXimDOcCpD64 X6WHStiU+II2uxk73igF03YyRe+mqwSuW6H9Qtdv7u/DWvtDubpnzfk1YriCRr9za8v5 XC2S0BuPZrz2o6+CZXODj0TbYeG2KwCM2cVe6oSpp9pVUDXxGg9olTtkau7Q+5+NsYc4 cPFBjLGEPHFWzzeOrmDbwFXicua/PB03j/rs7FblIcXdCvm1JDi0Tcgqxr22anUmw5R3 tGRsDEZo6/EsKO19A+OOzPNIS7W+AHqe2QZk6VRckV7ELyCwNp6MWsNbX2FhgYUyMfrE CxsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682105092; x=1684697092; 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=lvkLA+a8YoW/wuOsjaIxJzuPVSb1YjjMK/JpWWUYlMo=; b=lts9+4jzJCMEq44G+YMNy30GxuW5o8KWVwE7KHbMuwwgCaVQZJ57DoqxLR/POvFDbe hL3UUXr6MqYsyUki3TijOrhPVat705whRDV9BgVoOaWPKuBqQj59EfuO1JfjFNeZOJ9N DwV2YI5JnoE2qARLCCsl0WegRIyFQtNgDXboQ7KX0KyucyTekxN1FjPCjU0wKhezrlZT BR6vurVXEBf20RuCBTF3DLg3/pYLdD/w+XPG1JZeiBElQS0Jmmo9YE2fcZ45VkEHZvgA f9VdNudeXSTuYwuSgyR2Wn1yq08bcCdn6P6j9e87ZQKbsYQnwmmODn435TMqp76InKIL cuKg== X-Gm-Message-State: AAQBX9dSOQ5LAzxrgZtIkxrtaMaGA89WYlhUjeUGsAEb2icL7y6yeOmi tZZwj3O1SF06+DIjVdpN+rlD74kWSVqrOMqKrsmjbg== X-Received: by 2002:a17:903:22c8:b0:1a6:c12d:9036 with SMTP id y8-20020a17090322c800b001a6c12d9036mr7907063plg.33.1682105092516; Fri, 21 Apr 2023 12:24:52 -0700 (PDT) MIME-Version: 1.0 References: <20230419221716.3603068-1-atishp@rivosinc.com> <20230419221716.3603068-46-atishp@rivosinc.com> <69ba1760-a079-fd8f-b079-fcb01e3eedec@intel.com> In-Reply-To: <69ba1760-a079-fd8f-b079-fcb01e3eedec@intel.com> From: Atish Kumar Patra Date: Sat, 22 Apr 2023 00:54:41 +0530 Message-ID: Subject: Re: [RFC 45/48] RISC-V: ioremap: Implement for arch specific ioremap hooks To: Dave Hansen Cc: linux-kernel@vger.kernel.org, Rajnesh Kanwal , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Christoph Hellwig , Conor Dooley , Greg Kroah-Hartman , Guo Ren , Heiko Stuebner , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Mayuresh Chitale , Palmer Dabbelt , Paolo Bonzini , Paul Walmsley , Uladzislau Rezki Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Fri, Apr 21, 2023 at 3:46=E2=80=AFAM Dave Hansen = wrote: > > On 4/19/23 15:17, Atish Patra wrote: > > The guests running in CoVE must notify the host about its mmio regions > > so that host can enable mmio emulation. > > This one doesn't make a lot of sense to me. > > The guest and host must agree about the guest's physical layout up > front. In general, the host gets to dictate that layout. It tells the > guest, up front, what is present in the guest physical address space. > That is passed through DT/ACPI (which will be measured) to the guest. > This callback appears to say to the host: > > Hey, I (the guest) am treating this guest physical area as MMIO. > > But the host and guest have to agree _somewhere_ what the MMIO is used > for, not just that it is being used as MMIO. > Yes. The TSM (TEE Security Manager) which is equivalent to TDX also needs to be aware of the MMIO regions so that it can forward the faults accordingly. Most of the MMIO is emulated in the host (userspace or kernel emulation if present). The host is outside the trust boundary of the guest. Thus, guest needs to make sure the host only emulates the designated MMIO region. Otherwise, it opens an attack surface from a malicious host. All other confidential computing solutions also depend on guest initiated MMIO as well. AFAIK, the TDX & SEV relies on #VE like exceptions to invoke that while this patch is similar to what pkvm does. This approach lets the enlightened guest control which MMIO regions it wants the host to emulate. It can be a subset of the region's host provided the layout. The guest device filtering solution is based on this idea as well [1]. [1] https://lore.kernel.org/all/20210930010511.3387967-1-sathyanarayanan.ku= ppuswamy@linux.intel.com/ >