Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2587953pxb; Tue, 24 Aug 2021 02:48:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypkhWxlOTZkbRWNReQZpu7eN1vzP+Rcoh8jUmp0C4xXJuhGMBaxzmVMOEpGoehu6GHiLi+ X-Received: by 2002:a05:6e02:eca:: with SMTP id i10mr25261483ilk.27.1629798490037; Tue, 24 Aug 2021 02:48:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629798490; cv=none; d=google.com; s=arc-20160816; b=I1hXoRPXN+CjIZbaip4nUd1kZNwOLPRFv+gZRzyeC7t9am9E6wXWT7F7krAwy6lfW5 r8mX5pFE8bdwKSpc5pGER3PQHryOWoE56cLun5xJx4BeMZpGTirDlD8DpxYECwhdJeAS qtc6xuzn4Ucu0jJxgbPHFnNfiSncUA9SgFic83szCtoAi0PtR0XxBcVgvZiKvJEm/+cK bf+AX41DFSMreVDw03+sP9keToFOp3yxCz61mIfVKrcfPa5V4bUfmo0nHrwkbCD4iu8d tJCfvuj4Q/3Ji12g8BBThtMRQWMjHPVlPi83KV9NXaW/Oi1b50mRJjiiUNKbM+YTvlTC dhpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=byOliS/hAlH982j95uoj9FjiMsaJUQkzdYQOZKOZeFM=; b=hVKC2XzGpclC1mu3YqPAGXSFcgdDSUqb4hs1K6kO3uVY3oh4bXsJhk5QJluMHkk3aq KtgeEgzmFwXQMVeHUsJV9z3aRwefgDUfohqLMt+KSIFKfUrlSTSGM2Ob8mmQ1xSzSzXF qbQYydeD4UIrz2F9NNv2MxC10QjVWwYCoPP+u2qpvR3sp0cAUmDbiH2Ul9HjTTjMvoA2 0MfudtoXdIPQm6NFy7IY6l67+wO/0jeR5Iiu1oJyAXSOh0CLRkRK56dYYL0WbhZ6gvEn 1fDca0p6wFZszMYZJpXmfHX8NEP+4FKWwyEteTGkIcdhkhC6GCi39Du5uoQMfg64MstT XIfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EpSjaKaO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n123si19786865iof.15.2021.08.24.02.47.58; Tue, 24 Aug 2021 02:48:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EpSjaKaO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235721AbhHXJsA (ORCPT + 99 others); Tue, 24 Aug 2021 05:48:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45161 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235758AbhHXJr7 (ORCPT ); Tue, 24 Aug 2021 05:47:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629798435; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=byOliS/hAlH982j95uoj9FjiMsaJUQkzdYQOZKOZeFM=; b=EpSjaKaORit2KBe35XMrcFltkhci8RVMV7pN97m/XqxyihAXn2G+tohwnWuAezzH4bp48M efD8nrjBZJ6yjreif7/fjD3rTeTWH11Tav+ryGfZYH2nwH71eP7mowc9EipQYYwbSrgdrl bEd+dJo0mtOfCZWeq1ubGE6hNpUgYI4= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-454-6jh04HbePSu7z47xBXvETA-1; Tue, 24 Aug 2021 05:47:14 -0400 X-MC-Unique: 6jh04HbePSu7z47xBXvETA-1 Received: by mail-ej1-f69.google.com with SMTP id o7-20020a170906288700b005bb05cb6e25so6859144ejd.23 for ; Tue, 24 Aug 2021 02:47:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=byOliS/hAlH982j95uoj9FjiMsaJUQkzdYQOZKOZeFM=; b=FY7jQr2sO2bg5KKYIFPJ2+KOeORgct8kRb6hmPDG1a3quhlmerKL8uOFn6BbSPO1e8 t44A2+CRJZLyf5c45yUh3evdqSjz5Lq21QTbzF8Mu5gZhtPMpRsmSgr+OPbGXYYmwytF RuN6ydyvKKVTQzi6sFT0kRQqdtizRUsXc50APAbUJ/uZ1aOWYjagtLieDQUwFYa2/KD+ 4T180F2obEtw7KvqXgQkt1VxCxNDN6kgkBFmFKndkC/kakOPiJUKAoYAFUNPV8dKyCEt +hZ/+i+hpyiEquHn/THVWnmKU5KuP9tuHxyd6p0wZk43tgNyOKC2JgA4AteoJ10m4DCW 8BUQ== X-Gm-Message-State: AOAM533HnTQqLeRHwNGflkAXSMncG4QcuyscPMbVRGof8DdRDbFa8wUl VmsVneehVZmXACm5riRVbLU6hmOJTMoIOCB7KZvmBgreHZRTBGOxEP4/0TRdnvb9PbIToGxtIKd +qnOBKSXgnI9ZDMh9PoMqgo9X X-Received: by 2002:a17:906:3542:: with SMTP id s2mr40413092eja.379.1629798433290; Tue, 24 Aug 2021 02:47:13 -0700 (PDT) X-Received: by 2002:a17:906:3542:: with SMTP id s2mr40413054eja.379.1629798433111; Tue, 24 Aug 2021 02:47:13 -0700 (PDT) Received: from redhat.com ([2.55.137.225]) by smtp.gmail.com with ESMTPSA id b18sm2800522ejl.90.2021.08.24.02.47.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Aug 2021 02:47:12 -0700 (PDT) Date: Tue, 24 Aug 2021 05:47:03 -0400 From: "Michael S. Tsirkin" To: Andi Kleen Cc: Dan Williams , "Kuppuswamy, Sathyanarayanan" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Peter Zijlstra , Andy Lutomirski , Bjorn Helgaas , Richard Henderson , Thomas Bogendoerfer , James E J Bottomley , Helge Deller , "David S . Miller" , Arnd Bergmann , Jonathan Corbet , Peter H Anvin , Dave Hansen , Tony Luck , Kirill Shutemov , Sean Christopherson , Kuppuswamy Sathyanarayanan , X86 ML , Linux Kernel Mailing List , Linux PCI , linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, sparclinux@vger.kernel.org, linux-arch , Linux Doc Mailing List , virtualization@lists.linux-foundation.org Subject: Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range} Message-ID: <20210824053830-mutt-send-email-mst@kernel.org> References: <20210805005218.2912076-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20210805005218.2912076-12-sathyanarayanan.kuppuswamy@linux.intel.com> <20210823195409-mutt-send-email-mst@kernel.org> <26a3cce5-ddf7-cbe6-a41e-58a2aea48f78@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 23, 2021 at 07:14:18PM -0700, Andi Kleen wrote: > > On 8/23/2021 6:04 PM, Dan Williams wrote: > > On Mon, Aug 23, 2021 at 5:31 PM Kuppuswamy, Sathyanarayanan > > wrote: > > > > > > > > > On 8/23/21 4:56 PM, Michael S. Tsirkin wrote: > > > > > Add a new variant of pci_iomap for mapping all PCI resources > > > > > of a devices as shared memory with a hypervisor in a confidential > > > > > guest. > > > > > > > > > > Signed-off-by: Andi Kleen > > > > > Signed-off-by: Kuppuswamy Sathyanarayanan > > > > I'm a bit puzzled by this part. So why should the guest*not* map > > > > pci memory as shared? And if the answer is never (as it seems to be) > > > > then why not just make regular pci_iomap DTRT? > > > It is in the context of confidential guest (where VMM is un-trusted). So > > > we don't want to make all PCI resource as shared. It should be allowed > > > only for hardened drivers/devices. > > That's confusing, isn't device authorization what keeps unaudited > > drivers from loading against untrusted devices? I'm feeling like > > Michael that this should be a detail that drivers need not care about > > explicitly, in which case it does not need to be exported because the > > detail can be buried in lower levels. > > We originally made it default (similar to AMD), but it during code audit we > found a lot of drivers who do ioremap early outside the probe function. > Since it would be difficult to change them all we made it opt-in, which > ensures that only drivers that have been enabled can talk with the host at > all and can't be attacked. That made the problem of hardening all these > drivers a lot more practical. > > Currently we only really need virtio and MSI-X shared, so for changing two > places in the tree you avoid a lot of headache elsewhere. > > Note there is still a command line option to override if you want to allow > and load other drivers. > > -Andi I see. Hmm. It's a bit of a random thing to do it at the map time though. E.g. DMA is all handled transparently behind the DMA API. Hardening is much more than just replacing map with map_shared and I suspect what you will end up with is basically vendors replacing map with map shared to make things work for their users and washing their hands. I would say an explicit flag in the driver that says "hardened" and refusing to init a non hardened one would be better. -- MST