Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5622460rwr; Mon, 24 Apr 2023 06:55:51 -0700 (PDT) X-Google-Smtp-Source: AKy350YLxGIgGPC4tNsQAisqBQG7kB8/sWqHAYfIbH4zUxl0/0qs41oc9UQDnbuIJlq+nJh5Z0cs X-Received: by 2002:a05:6a21:99a0:b0:ee:bcf3:be0c with SMTP id ve32-20020a056a2199a000b000eebcf3be0cmr18624331pzb.0.1682344550887; Mon, 24 Apr 2023 06:55:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682344550; cv=none; d=google.com; s=arc-20160816; b=AamcFBAK29GYGsh7wuCHIadzKSRLSoQkHTReI8EunKKR5h5Hbfsx1Uieo3kM3guRbB 5A5hVFLYA1fb5NB26G4+DGYfHdI4/+cQKGTaBP/4/z+eHyL0Mb0MmO8QsfWoEYVuTAVf 4apAi/eFhTr3I/TJU+W3Fs4IeKLCybJoCqEMWsi4BqVQ8+o+YUN9KJ+pWh9V0gJjqfB8 PZmhrypJo0NiW+50qvRYyukFshyC7MqDDs5W8r1YOyxkrdVEyvSmYdrKGbLrCaoYCOoX p6H7jMcevKmMUYvt9nmSR1vj2QbzCn8WdpOF+zmhMwsASmxwSja+JtDpow3abKIbbP44 gK3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=VjD0/W6bpStly7qGmOiG+LBZGTGYGwKdNVzP3Gqoe30=; b=ftWu3LyMoG3mJYS6C020LkDxa78rh/q0uXkigCp8hMxtjmW+7pPi9IXhf8aiRQ9PwV miLHq7ASfakgfbtDyCiWokmP3DTP40bgY+zgD1Zdp0+D7YuFHY/WV5HwKHFr/VfSSzjU 0FuzW/ZSyDHpCrWOJXMObKyNggD1hnxB1xDLt2wJ7hr6U9DxEMZuQ4YydPeFhLtKzWrp oGBoaCzX0tmxT2hJkoG2svGDAssiMJVgJhvzbY1V427Vs1eSfljqxQoT/6wlGGLR5ZXa 51CkEms0wGMWEsaDl+0ujMzzQbE+56XuY4wqWh/lpb74CzQCN9NnFtysPmDBfRQj450u rxIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BSlADEd7; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y30-20020a63495e000000b0050be719abc9si10573763pgk.167.2023.04.24.06.55.36; Mon, 24 Apr 2023 06:55:50 -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=@intel.com header.s=Intel header.b=BSlADEd7; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231737AbjDXNsr (ORCPT + 99 others); Mon, 24 Apr 2023 09:48:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231325AbjDXNsb (ORCPT ); Mon, 24 Apr 2023 09:48:31 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1943D83DE; Mon, 24 Apr 2023 06:48:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682344104; x=1713880104; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=oPqlnm5FAEkzjCzsM5wwOi+X/O97WzQZ5VPCNK7UoWo=; b=BSlADEd7/kIe/sZ0Rqu/+ceaXxHopDQlqj4L8L3b1fx1CLJ69t6C8F2f 9UWAxbFOE17aKW7uhHNtmCPcRczn47PjhV3oO+orC5oToJinZtba78T9d gRH/r+dgOytrFrgArMKZEB10FJSDaL61t3lktL19/mz0WkcI2mrr3+hT7 /6RtTCSj1nLWbP/8pmC0hK8bow+szUFT/Xvdwu8OHI7PEBSPz4vE10+qP mazCBP2rUxsgfQbSL1UQXfM4JVr1SYNZ+s+xEIZw+AlfAdfbpg+AdCyW9 SDi3mXGaGeNfbJW62mkMNyv21wisVEQ7m4Sk7J107fUC+8HB2ZttFoJjQ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10690"; a="346479854" X-IronPort-AV: E=Sophos;i="5.99,222,1677571200"; d="scan'208";a="346479854" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2023 06:48:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10690"; a="693087845" X-IronPort-AV: E=Sophos;i="5.99,222,1677571200"; d="scan'208";a="693087845" Received: from mkavai-mobl2.amr.corp.intel.com (HELO [10.212.196.194]) ([10.212.196.194]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2023 06:48:09 -0700 Message-ID: <81c476f4-ef62-e4a6-0033-8a46a15379fd@intel.com> Date: Mon, 24 Apr 2023 06:48:09 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [RFC 45/48] RISC-V: ioremap: Implement for arch specific ioremap hooks Content-Language: en-US To: Atish Kumar Patra 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 References: <20230419221716.3603068-1-atishp@rivosinc.com> <20230419221716.3603068-46-atishp@rivosinc.com> <69ba1760-a079-fd8f-b079-fcb01e3eedec@intel.com> From: Dave Hansen In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 4/21/23 12:24, Atish Kumar Patra wrote: > On Fri, Apr 21, 2023 at 3:46 AM Dave Hansen wrote:>> 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. How does this mechanism stop the host from emulating something outside the designated region? On TDX, for instance, the guest page table have a shared/private bit. Private pages get TDX protections to (among other things) keep the page contents confidential from the host. Shared pages can be used for MMIO and don't have those protections. If the host goes and tries to flip a page from private->shared, TDX protections will kick in and prevent it. None of this requires the guest to tell the host where it expects MMIO to be located. > 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. I'm not _quite_ sure what "guest initiated" means. But SEV and TDX don't require an ioremap hook like this. So, even if they *are* "guest initiated", the question still remains how they work without this patch, or what they are missing without it. > 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.kuppuswamy@linux.intel.com/ I don't really see the connection. Even if that series was going forward (I'm not sure it is) there is no ioremap hook there. There's also no guest->host communication in that series. The guest doesn't _tell_ the host where the MMIO is, it just declines to run code for devices that it didn't expect to see. I'm still rather confused here.