* Re: [PATCH v4 10/15] asm/io.h: Add ioremap_shared fallback
[not found] ` <20210805005218.2912076-11-sathyanarayanan.kuppuswamy@linux.intel.com>
@ 2021-08-12 19:46 ` Bjorn Helgaas
2021-08-13 7:58 ` Christoph Hellwig
1 sibling, 0 replies; 33+ messages in thread
From: Bjorn Helgaas @ 2021-08-12 19:46 UTC (permalink / raw)
To: Kuppuswamy Sathyanarayanan
Cc: Kuppuswamy Sathyanarayanan, Michael S . Tsirkin, Peter Zijlstra,
linux-pci, linux-mips, James E J Bottomley, Dave Hansen,
Peter H Anvin, sparclinux, Thomas Gleixner, linux-arch,
Andi Kleen, Jonathan Corbet, Helge Deller, x86, Ingo Molnar,
Arnd Bergmann, Tony Luck, Borislav Petkov, Andy Lutomirski,
Bjorn Helgaas, Dan Williams, virtualization, Richard Henderson,
Thomas Bogendoerfer, linux-parisc, Sean Christopherson, linux-doc,
linux-kernel, linux-alpha, David S . Miller, Kirill Shutemov
On Wed, Aug 04, 2021 at 05:52:13PM -0700, Kuppuswamy Sathyanarayanan wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> This function is for declaring memory that should be shared with
> a hypervisor in a confidential guest. If the architecture doesn't
> implement it it's just ioremap.
I would assume ioremap_shared() would "map" something, not "declare"
it.
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
> ---
> arch/alpha/include/asm/io.h | 1 +
> arch/mips/include/asm/io.h | 1 +
> arch/parisc/include/asm/io.h | 1 +
> arch/sparc/include/asm/io_64.h | 1 +
> include/asm-generic/io.h | 4 ++++
> 5 files changed, 8 insertions(+)
>
> diff --git a/arch/alpha/include/asm/io.h b/arch/alpha/include/asm/io.h
> index 0fab5ac90775..701b44909b94 100644
> --- a/arch/alpha/include/asm/io.h
> +++ b/arch/alpha/include/asm/io.h
> @@ -283,6 +283,7 @@ static inline void __iomem *ioremap(unsigned long port, unsigned long size)
> }
>
> #define ioremap_wc ioremap
> +#define ioremap_shared ioremap
> #define ioremap_uc ioremap
>
> static inline void iounmap(volatile void __iomem *addr)
> diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
> index 6f5c86d2bab4..3713ff624632 100644
> --- a/arch/mips/include/asm/io.h
> +++ b/arch/mips/include/asm/io.h
> @@ -179,6 +179,7 @@ void iounmap(const volatile void __iomem *addr);
> #define ioremap(offset, size) \
> ioremap_prot((offset), (size), _CACHE_UNCACHED)
> #define ioremap_uc ioremap
> +#define ioremap_shared ioremap
>
> /*
> * ioremap_cache - map bus memory into CPU space
> diff --git a/arch/parisc/include/asm/io.h b/arch/parisc/include/asm/io.h
> index 0b5259102319..73064e152df7 100644
> --- a/arch/parisc/include/asm/io.h
> +++ b/arch/parisc/include/asm/io.h
> @@ -129,6 +129,7 @@ static inline void gsc_writeq(unsigned long long val, unsigned long addr)
> */
> void __iomem *ioremap(unsigned long offset, unsigned long size);
> #define ioremap_wc ioremap
> +#define ioremap_shared ioremap
> #define ioremap_uc ioremap
>
> extern void iounmap(const volatile void __iomem *addr);
> diff --git a/arch/sparc/include/asm/io_64.h b/arch/sparc/include/asm/io_64.h
> index 5ffa820dcd4d..18cc656eb712 100644
> --- a/arch/sparc/include/asm/io_64.h
> +++ b/arch/sparc/include/asm/io_64.h
> @@ -409,6 +409,7 @@ static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
> #define ioremap_uc(X,Y) ioremap((X),(Y))
> #define ioremap_wc(X,Y) ioremap((X),(Y))
> #define ioremap_wt(X,Y) ioremap((X),(Y))
> +#define ioremap_shared(X, Y) ioremap((X), (Y))
> static inline void __iomem *ioremap_np(unsigned long offset, unsigned long size)
> {
> return NULL;
> diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
> index e93375c710b9..bfcaee1691c8 100644
> --- a/include/asm-generic/io.h
> +++ b/include/asm-generic/io.h
> @@ -982,6 +982,10 @@ static inline void __iomem *ioremap(phys_addr_t addr, size_t size)
> #define ioremap_wt ioremap
> #endif
>
> +#ifndef ioremap_shared
> +#define ioremap_shared ioremap
> +#endif
"ioremap_shared" is a very generic term for a pretty specific thing:
"memory shared with a hypervisor in a confidential guest".
Maybe deserves a comment with at least a hint here. "Hypervisors in a
confidential guest" isn't the first thing that comes to mind when I
read "shared".
> /*
> * ioremap_uc is special in that we do require an explicit architecture
> * implementation. In general you do not want to use this function in a
> --
> 2.25.1
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 10/15] asm/io.h: Add ioremap_shared fallback
[not found] ` <20210805005218.2912076-11-sathyanarayanan.kuppuswamy@linux.intel.com>
2021-08-12 19:46 ` [PATCH v4 10/15] asm/io.h: Add ioremap_shared fallback Bjorn Helgaas
@ 2021-08-13 7:58 ` Christoph Hellwig
1 sibling, 0 replies; 33+ messages in thread
From: Christoph Hellwig @ 2021-08-13 7:58 UTC (permalink / raw)
To: Kuppuswamy Sathyanarayanan
Cc: Kuppuswamy Sathyanarayanan, Michael S . Tsirkin, Peter Zijlstra,
linux-pci, linux-mips, James E J Bottomley, Dave Hansen,
Peter H Anvin, sparclinux, Thomas Gleixner, linux-arch,
Andi Kleen, Jonathan Corbet, Helge Deller, x86, Ingo Molnar,
Arnd Bergmann, Tony Luck, Borislav Petkov, Andy Lutomirski,
Bjorn Helgaas, Dan Williams, virtualization, Richard Henderson,
Thomas Bogendoerfer, linux-parisc, Sean Christopherson, linux-doc,
linux-kernel, linux-alpha, David S . Miller, Kirill Shutemov
_shared is just a horrible name for these. Please find a more specific
name, and document them instead of just adding to the macro forrest.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
[not found] ` <20210805005218.2912076-12-sathyanarayanan.kuppuswamy@linux.intel.com>
@ 2021-08-13 8:02 ` Christoph Hellwig
2021-08-23 23:56 ` Michael S. Tsirkin
1 sibling, 0 replies; 33+ messages in thread
From: Christoph Hellwig @ 2021-08-13 8:02 UTC (permalink / raw)
To: Kuppuswamy Sathyanarayanan
Cc: Kuppuswamy Sathyanarayanan, Michael S . Tsirkin, Peter Zijlstra,
linux-pci, linux-mips, James E J Bottomley, Dave Hansen,
Peter H Anvin, sparclinux, Thomas Gleixner, linux-arch,
Andi Kleen, Jonathan Corbet, Helge Deller, x86, Ingo Molnar,
Arnd Bergmann, Tony Luck, Borislav Petkov, Andy Lutomirski,
Bjorn Helgaas, Dan Williams, virtualization, Richard Henderson,
Thomas Bogendoerfer, linux-parisc, Sean Christopherson, linux-doc,
linux-kernel, linux-alpha, David S . Miller, Kirill Shutemov
On Wed, Aug 04, 2021 at 05:52:14PM -0700, Kuppuswamy Sathyanarayanan wrote:
> +extern void __iomem *pci_iomap_shared(struct pci_dev *dev, int bar,
> + unsigned long max);
> +extern void __iomem *pci_iomap_shared_range(struct pci_dev *dev, int bar,
> + unsigned long offset,
> + unsigned long maxlen);
No need for externs here.
> +/**
> + * pci_iomap_shared_range - create a virtual shared mapping cookie for a
> + * PCI BAR
This reads like completely garbage from a markow chain.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 12/15] pci: Mark MSI data shared
[not found] ` <20210805005218.2912076-13-sathyanarayanan.kuppuswamy@linux.intel.com>
@ 2021-08-13 8:07 ` Christoph Hellwig
0 siblings, 0 replies; 33+ messages in thread
From: Christoph Hellwig @ 2021-08-13 8:07 UTC (permalink / raw)
To: Kuppuswamy Sathyanarayanan
Cc: Kuppuswamy Sathyanarayanan, Michael S . Tsirkin, Peter Zijlstra,
linux-pci, linux-mips, James E J Bottomley, Dave Hansen,
Peter H Anvin, sparclinux, Thomas Gleixner, linux-arch,
Andi Kleen, Jonathan Corbet, Helge Deller, x86, Ingo Molnar,
Arnd Bergmann, Tony Luck, Borislav Petkov, Andy Lutomirski,
Bjorn Helgaas, Dan Williams, virtualization, Richard Henderson,
Thomas Bogendoerfer, linux-parisc, Sean Christopherson, linux-doc,
linux-kernel, linux-alpha, David S . Miller, Kirill Shutemov
On Wed, Aug 04, 2021 at 05:52:15PM -0700, Kuppuswamy Sathyanarayanan wrote:
>
> - return ioremap(phys_addr, nr_entries * PCI_MSIX_ENTRY_SIZE);
> + return ioremap_shared(phys_addr, nr_entries * PCI_MSIX_ENTRY_SIZE);
Please add a comment here. I also find the amount of ioremap_* variants
rather frustrating. Maybe it it is time for a ioremap_flags which
replaces the too-lowlevel pgprot_t of the ioremap_prot provided by some
architectures with a more highlevel flags arguments that could also
provide an accessible to the hypervisor flag.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
[not found] ` <20210805005218.2912076-12-sathyanarayanan.kuppuswamy@linux.intel.com>
2021-08-13 8:02 ` [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range} Christoph Hellwig
@ 2021-08-23 23:56 ` Michael S. Tsirkin
[not found] ` <26a3cce5-ddf7-cbe6-a41e-58a2aea48f78@linux.intel.com>
1 sibling, 1 reply; 33+ messages in thread
From: Michael S. Tsirkin @ 2021-08-23 23:56 UTC (permalink / raw)
To: Kuppuswamy Sathyanarayanan
Cc: Kuppuswamy Sathyanarayanan, linux-doc, Peter Zijlstra, linux-pci,
linux-mips, James E J Bottomley, Dave Hansen, Peter H Anvin,
sparclinux, Thomas Gleixner, linux-arch, Andi Kleen,
Jonathan Corbet, Helge Deller, x86, Ingo Molnar, Arnd Bergmann,
Tony Luck, Borislav Petkov, Andy Lutomirski, Bjorn Helgaas,
Dan Williams, virtualization, Richard Henderson,
Thomas Bogendoerfer, linux-parisc, Sean Christopherson,
linux-kernel, linux-alpha, David S . Miller, Kirill Shutemov
On Wed, Aug 04, 2021 at 05:52:14PM -0700, Kuppuswamy Sathyanarayanan wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> 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 <ak@linux.intel.com>
> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
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?
Thanks!
> ---
> include/asm-generic/pci_iomap.h | 6 +++++
> lib/pci_iomap.c | 46 +++++++++++++++++++++++++++++++++
> 2 files changed, 52 insertions(+)
>
> diff --git a/include/asm-generic/pci_iomap.h b/include/asm-generic/pci_iomap.h
> index d4f16dcc2ed7..0178ddd7ad88 100644
> --- a/include/asm-generic/pci_iomap.h
> +++ b/include/asm-generic/pci_iomap.h
> @@ -18,6 +18,12 @@ extern void __iomem *pci_iomap_range(struct pci_dev *dev, int bar,
> extern void __iomem *pci_iomap_wc_range(struct pci_dev *dev, int bar,
> unsigned long offset,
> unsigned long maxlen);
> +extern void __iomem *pci_iomap_shared(struct pci_dev *dev, int bar,
> + unsigned long max);
> +extern void __iomem *pci_iomap_shared_range(struct pci_dev *dev, int bar,
> + unsigned long offset,
> + unsigned long maxlen);
> +
> /* Create a virtual mapping cookie for a port on a given PCI device.
> * Do not call this directly, it exists to make it easier for architectures
> * to override */
> diff --git a/lib/pci_iomap.c b/lib/pci_iomap.c
> index 6251c3f651c6..b04e8689eab3 100644
> --- a/lib/pci_iomap.c
> +++ b/lib/pci_iomap.c
> @@ -25,6 +25,11 @@ static void __iomem *map_ioremap_wc(phys_addr_t addr, size_t size)
> return ioremap_wc(addr, size);
> }
>
> +static void __iomem *map_ioremap_shared(phys_addr_t addr, size_t size)
> +{
> + return ioremap_shared(addr, size);
> +}
> +
> static void __iomem *pci_iomap_range_map(struct pci_dev *dev,
> int bar,
> unsigned long offset,
> @@ -101,6 +106,47 @@ void __iomem *pci_iomap_wc_range(struct pci_dev *dev,
> }
> EXPORT_SYMBOL_GPL(pci_iomap_wc_range);
>
> +/**
> + * pci_iomap_shared_range - create a virtual shared mapping cookie for a
> + * PCI BAR
> + * @dev: PCI device that owns the BAR
> + * @bar: BAR number
> + * @offset: map memory at the given offset in BAR
> + * @maxlen: max length of the memory to map
> + *
> + * Remap a pci device's resources shared in a confidential guest.
> + * For more details see pci_iomap_range's documentation.
> + *
> + * @maxlen specifies the maximum length to map. To get access to
> + * the complete BAR from offset to the end, pass %0 here.
> + */
> +void __iomem *pci_iomap_shared_range(struct pci_dev *dev, int bar,
> + unsigned long offset, unsigned long maxlen)
> +{
> + return pci_iomap_range_map(dev, bar, offset, maxlen,
> + map_ioremap_shared);
> +}
> +EXPORT_SYMBOL_GPL(pci_iomap_shared_range);
> +
> +/**
> + * pci_iomap_shared - create a virtual shared mapping cookie for a PCI BAR
> + * @dev: PCI device that owns the BAR
> + * @bar: BAR number
> + * @maxlen: length of the memory to map
> + *
> + * See pci_iomap for details. This function creates a shared mapping
> + * with the host for confidential hosts.
> + *
> + * @maxlen specifies the maximum length to map. To get access to the
> + * complete BAR without checking for its length first, pass %0 here.
> + */
> +void __iomem *pci_iomap_shared(struct pci_dev *dev, int bar,
> + unsigned long maxlen)
> +{
> + return pci_iomap_shared_range(dev, bar, 0, maxlen);
> +}
> +EXPORT_SYMBOL_GPL(pci_iomap_shared);
> +
> /**
> * pci_iomap - create a virtual mapping cookie for a PCI BAR
> * @dev: PCI device that owns the BAR
> --
> 2.25.1
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
[not found] ` <26a3cce5-ddf7-cbe6-a41e-58a2aea48f78@linux.intel.com>
@ 2021-08-24 1:04 ` Dan Williams
2021-08-24 2:14 ` Andi Kleen
[not found] ` <CACK8Z6E+__kZqU8mVUnYhFc0wz_e81qBLO3ffqSDghVtztNeQw@mail.gmail.com>
2021-08-24 7:07 ` Christoph Hellwig
2021-08-24 9:12 ` Michael S. Tsirkin
2 siblings, 2 replies; 33+ messages in thread
From: Dan Williams @ 2021-08-24 1:04 UTC (permalink / raw)
To: Kuppuswamy, Sathyanarayanan
Cc: Kuppuswamy Sathyanarayanan, Michael S. Tsirkin, Peter Zijlstra,
Linux PCI, linux-mips, James E J Bottomley, Dave Hansen,
Peter H Anvin, sparclinux, linux-arch, Andi Kleen,
Jonathan Corbet, Helge Deller, X86 ML, Ingo Molnar, Arnd Bergmann,
Tony Luck, Borislav Petkov, Andy Lutomirski, Bjorn Helgaas,
Thomas Gleixner, virtualization, Richard Henderson,
Thomas Bogendoerfer, linux-parisc, Sean Christopherson,
Linux Doc Mailing List, Linux Kernel Mailing List, linux-alpha,
David S . Miller, Kirill Shutemov
On Mon, Aug 23, 2021 at 5:31 PM Kuppuswamy, Sathyanarayanan
<sathyanarayanan.kuppuswamy@linux.intel.com> 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<ak@linux.intel.com>
> >> Signed-off-by: Kuppuswamy Sathyanarayanan<sathyanarayanan.kuppuswamy@linux.intel.com>
> > 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.
Note, I specifically said "unaudited", not "hardened" because as Greg
mentioned the kernel must trust drivers, its devices that may not be
trusted.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-08-24 1:04 ` Dan Williams
@ 2021-08-24 2:14 ` Andi Kleen
2021-08-24 9:47 ` Michael S. Tsirkin
[not found] ` <CACK8Z6E+__kZqU8mVUnYhFc0wz_e81qBLO3ffqSDghVtztNeQw@mail.gmail.com>
1 sibling, 1 reply; 33+ messages in thread
From: Andi Kleen @ 2021-08-24 2:14 UTC (permalink / raw)
To: Dan Williams, Kuppuswamy, Sathyanarayanan
Cc: Kuppuswamy Sathyanarayanan, Michael S. Tsirkin, Peter Zijlstra,
Linux PCI, linux-mips, James E J Bottomley, Dave Hansen,
Peter H Anvin, sparclinux, linux-arch, Jonathan Corbet,
Helge Deller, X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck,
Borislav Petkov, Andy Lutomirski, Bjorn Helgaas, Thomas Gleixner,
virtualization, Richard Henderson, Thomas Bogendoerfer,
linux-parisc, Sean Christopherson, Linux Doc Mailing List,
Linux Kernel Mailing List, linux-alpha, David S . Miller,
Kirill Shutemov
On 8/23/2021 6:04 PM, Dan Williams wrote:
> On Mon, Aug 23, 2021 at 5:31 PM Kuppuswamy, Sathyanarayanan
> <sathyanarayanan.kuppuswamy@linux.intel.com> 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<ak@linux.intel.com>
>>>> Signed-off-by: Kuppuswamy Sathyanarayanan<sathyanarayanan.kuppuswamy@linux.intel.com>
>>> 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
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
[not found] ` <26a3cce5-ddf7-cbe6-a41e-58a2aea48f78@linux.intel.com>
2021-08-24 1:04 ` Dan Williams
@ 2021-08-24 7:07 ` Christoph Hellwig
2021-08-24 17:04 ` Andi Kleen
2021-08-24 9:12 ` Michael S. Tsirkin
2 siblings, 1 reply; 33+ messages in thread
From: Christoph Hellwig @ 2021-08-24 7:07 UTC (permalink / raw)
To: Kuppuswamy, Sathyanarayanan
Cc: Kuppuswamy Sathyanarayanan, Michael S. Tsirkin, Peter Zijlstra,
linux-pci, linux-mips, James E J Bottomley, Dave Hansen,
Peter H Anvin, sparclinux, Thomas Gleixner, linux-arch,
Andi Kleen, Jonathan Corbet, Helge Deller, x86, Ingo Molnar,
Arnd Bergmann, Tony Luck, Borislav Petkov, Andy Lutomirski,
Bjorn Helgaas, Dan Williams, virtualization, Richard Henderson,
Thomas Bogendoerfer, linux-parisc, Sean Christopherson, linux-doc,
linux-kernel, linux-alpha, David S . Miller, Kirill Shutemov
On Mon, Aug 23, 2021 at 05:30:54PM -0700, 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<ak@linux.intel.com>
> > > Signed-off-by: Kuppuswamy Sathyanarayanan<sathyanarayanan.kuppuswamy@linux.intel.com>
> > 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.
Well, assuming the host can do any damage when mapped shared that also
means not mapping it shared will completely break the drivers.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
[not found] ` <26a3cce5-ddf7-cbe6-a41e-58a2aea48f78@linux.intel.com>
2021-08-24 1:04 ` Dan Williams
2021-08-24 7:07 ` Christoph Hellwig
@ 2021-08-24 9:12 ` Michael S. Tsirkin
2 siblings, 0 replies; 33+ messages in thread
From: Michael S. Tsirkin @ 2021-08-24 9:12 UTC (permalink / raw)
To: Kuppuswamy, Sathyanarayanan
Cc: Kuppuswamy Sathyanarayanan, linux-doc, Peter Zijlstra, linux-pci,
linux-mips, James E J Bottomley, Dave Hansen, Peter H Anvin,
sparclinux, Thomas Gleixner, linux-arch, Andi Kleen,
Jonathan Corbet, Helge Deller, x86, Ingo Molnar, Arnd Bergmann,
Tony Luck, Borislav Petkov, Andy Lutomirski, Bjorn Helgaas,
Dan Williams, virtualization, Richard Henderson,
Thomas Bogendoerfer, linux-parisc, Sean Christopherson,
linux-kernel, linux-alpha, David S . Miller, Kirill Shutemov
On Mon, Aug 23, 2021 at 05:30:54PM -0700, 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<ak@linux.intel.com>
> > > Signed-off-by: Kuppuswamy Sathyanarayanan<sathyanarayanan.kuppuswamy@linux.intel.com>
> > 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.
I can't say this answers the question at all. PCI devices are part of
the VMM and so un-trusted. In particular PCI devices do not have
the key to decrypt memory. Therefore as far as I can see PCI resources
should not be encrypted. I conclude they all should be marked
shared.
If I'm wrong can you please give an example of a PCI resource
that is encrypted?
--
MST
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-08-24 2:14 ` Andi Kleen
@ 2021-08-24 9:47 ` Michael S. Tsirkin
2021-08-24 17:20 ` Andi Kleen
0 siblings, 1 reply; 33+ messages in thread
From: Michael S. Tsirkin @ 2021-08-24 9:47 UTC (permalink / raw)
To: Andi Kleen
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Linux Doc Mailing List, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Thomas Gleixner, linux-arch, Jonathan Corbet, Helge Deller,
X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck, Borislav Petkov,
Andy Lutomirski, Bjorn Helgaas, Dan Williams, virtualization,
Richard Henderson, Thomas Bogendoerfer, linux-parisc,
Sean Christopherson, Linux Kernel Mailing List, linux-alpha,
David S . Miller, Kirill Shutemov
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
> > <sathyanarayanan.kuppuswamy@linux.intel.com> 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<ak@linux.intel.com>
> > > > > Signed-off-by: Kuppuswamy Sathyanarayanan<sathyanarayanan.kuppuswamy@linux.intel.com>
> > > > 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
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-08-24 7:07 ` Christoph Hellwig
@ 2021-08-24 17:04 ` Andi Kleen
2021-08-29 15:34 ` Michael S. Tsirkin
0 siblings, 1 reply; 33+ messages in thread
From: Andi Kleen @ 2021-08-24 17:04 UTC (permalink / raw)
To: Christoph Hellwig, Kuppuswamy, Sathyanarayanan
Cc: Kuppuswamy Sathyanarayanan, Michael S. Tsirkin, Peter Zijlstra,
linux-pci, linux-mips, James E J Bottomley, Dave Hansen,
Peter H Anvin, sparclinux, Thomas Gleixner, linux-arch,
Jonathan Corbet, Helge Deller, x86, Ingo Molnar, Arnd Bergmann,
Tony Luck, Borislav Petkov, Andy Lutomirski, Bjorn Helgaas,
Dan Williams, virtualization, Richard Henderson,
Thomas Bogendoerfer, linux-parisc, Sean Christopherson, linux-doc,
linux-kernel, linux-alpha, David S . Miller, Kirill Shutemov
On 8/24/2021 12:07 AM, Christoph Hellwig wrote:
> On Mon, Aug 23, 2021 at 05:30:54PM -0700, 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<ak@linux.intel.com>
>>>> Signed-off-by: Kuppuswamy Sathyanarayanan<sathyanarayanan.kuppuswamy@linux.intel.com>
>>> 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.
> Well, assuming the host can do any damage when mapped shared that also
> means not mapping it shared will completely break the drivers.
There are several cases:
- We have driver filtering active to protect you against attacks from
the host against unhardened drivers.
In this case the drivers not working is the intended behavior.
- There is an command allow list override for some new driver, but the
driver is hardened and shared
The other drivers will still not work, but that's also the intended behavior
- Driver filtering is disabled or the allow list override is used to
enable some non hardened/enabled driver
There is a command line option to override the ioremap sharing default,
it will allow all drivers to do ioremap. We would really prefer to make
it more finegrained, but it's not possible in this case. Other drivers
are likely attackable.
- Driver filtering is disabled (allowing attacks on the drivers) and the
command line option for forced sharing is set.
All drivers initialize and can talk to the host through MMIO. Lots of
unhardened drivers are likely attackable.
-Andi
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-08-24 9:47 ` Michael S. Tsirkin
@ 2021-08-24 17:20 ` Andi Kleen
2021-08-24 18:55 ` Bjorn Helgaas
2021-08-29 15:27 ` Michael S. Tsirkin
0 siblings, 2 replies; 33+ messages in thread
From: Andi Kleen @ 2021-08-24 17:20 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Linux Doc Mailing List, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Thomas Gleixner, linux-arch, Jonathan Corbet, Helge Deller,
X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck, Borislav Petkov,
Andy Lutomirski, Bjorn Helgaas, Dan Williams, virtualization,
Richard Henderson, Thomas Bogendoerfer, linux-parisc,
Sean Christopherson, Linux Kernel Mailing List, linux-alpha,
David S . Miller, Kirill Shutemov
> 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.
That concept exists too. There is a separate allow list for the drivers.
So just adding shared to a driver is not enough, until it's also added
to the allowlist
Users can of course chose to disable the allowlist, but they need to
understand the security implications.
>
> I would say an explicit flag in the driver that says "hardened"
> and refusing to init a non hardened one would be better.
We have that too (that's the device filtering)
But the problem is that device filtering just stops the probe functions,
not the initcalls, and lot of legacy drivers do MMIO interactions before
going into probe. In some cases it's unavoidable because of the device
doesn't have a separate enumeration mechanism it needs some kind of
probing to even check for its existence And since we don't want to
change all of them it's far safer to make the ioremap opt-in.
-Andi
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-08-24 17:20 ` Andi Kleen
@ 2021-08-24 18:55 ` Bjorn Helgaas
2021-08-24 20:14 ` Andi Kleen
2021-08-29 15:27 ` Michael S. Tsirkin
1 sibling, 1 reply; 33+ messages in thread
From: Bjorn Helgaas @ 2021-08-24 18:55 UTC (permalink / raw)
To: Andi Kleen
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Michael S. Tsirkin, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Rajat Jain, Thomas Gleixner, linux-arch, Jonathan Corbet,
Helge Deller, X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck,
Borislav Petkov, Andy Lutomirski, Bjorn Helgaas, Dan Williams,
virtualization, Richard Henderson, Thomas Bogendoerfer,
linux-parisc, Sean Christopherson, Linux Doc Mailing List,
Linux Kernel Mailing List, linux-alpha, David S . Miller,
Kirill Shutemov
[+cc Rajat; I still don't know what "shared memory with a hypervisor
in a confidential guest" means, but now we're talking about hardened
drivers and allow lists, which Rajat is interested in]
On Tue, Aug 24, 2021 at 10:20:44AM -0700, Andi Kleen wrote:
>
> > 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.
>
> That concept exists too. There is a separate allow list for the drivers. So
> just adding shared to a driver is not enough, until it's also added to the
> allowlist
>
> Users can of course chose to disable the allowlist, but they need to
> understand the security implications.
>
> > I would say an explicit flag in the driver that says "hardened"
> > and refusing to init a non hardened one would be better.
>
> We have that too (that's the device filtering)
>
> But the problem is that device filtering just stops the probe functions, not
> the initcalls, and lot of legacy drivers do MMIO interactions before going
> into probe. In some cases it's unavoidable because of the device doesn't
> have a separate enumeration mechanism it needs some kind of probing to even
> check for its existence And since we don't want to change all of them it's
> far safer to make the ioremap opt-in.
>
>
> -Andi
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-08-24 18:55 ` Bjorn Helgaas
@ 2021-08-24 20:14 ` Andi Kleen
2021-08-24 20:31 ` Bjorn Helgaas
0 siblings, 1 reply; 33+ messages in thread
From: Andi Kleen @ 2021-08-24 20:14 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Michael S. Tsirkin, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Rajat Jain, Thomas Gleixner, linux-arch, Jonathan Corbet,
Helge Deller, X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck,
Borislav Petkov, Andy Lutomirski, Bjorn Helgaas, Dan Williams,
virtualization, Richard Henderson, Thomas Bogendoerfer,
linux-parisc, Sean Christopherson, Linux Doc Mailing List,
Linux Kernel Mailing List, linux-alpha, David S . Miller,
Kirill Shutemov
On 8/24/2021 11:55 AM, Bjorn Helgaas wrote:
> [+cc Rajat; I still don't know what "shared memory with a hypervisor
> in a confidential guest" means,
A confidential guest is a guest which uses memory encryption to isolate
itself from the host. It doesn't trust the host. But it still needs to
communicate with the host for IO, so it has some special memory areas
that are explicitly marked shared. These are used to do IO with the
host. All their usage needs to be carefully hardened to avoid any
security attacks on the guest, that's why we want to limit this
interaction only to a small set of hardened drivers. For MMIO, the set
is currently only virtio and MSI-X.
-Andi
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-08-24 20:14 ` Andi Kleen
@ 2021-08-24 20:31 ` Bjorn Helgaas
2021-08-24 20:50 ` Andi Kleen
0 siblings, 1 reply; 33+ messages in thread
From: Bjorn Helgaas @ 2021-08-24 20:31 UTC (permalink / raw)
To: Andi Kleen
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Michael S. Tsirkin, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Rajat Jain, Thomas Gleixner, linux-arch, Jonathan Corbet,
Helge Deller, X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck,
Borislav Petkov, Andy Lutomirski, Bjorn Helgaas, Dan Williams,
virtualization, Richard Henderson, Thomas Bogendoerfer,
linux-parisc, Sean Christopherson, Linux Doc Mailing List,
Linux Kernel Mailing List, linux-alpha, David S . Miller,
Kirill Shutemov
On Tue, Aug 24, 2021 at 01:14:02PM -0700, Andi Kleen wrote:
>
> On 8/24/2021 11:55 AM, Bjorn Helgaas wrote:
> > [+cc Rajat; I still don't know what "shared memory with a hypervisor
> > in a confidential guest" means,
>
> A confidential guest is a guest which uses memory encryption to isolate
> itself from the host. It doesn't trust the host. But it still needs to
> communicate with the host for IO, so it has some special memory areas that
> are explicitly marked shared. These are used to do IO with the host. All
> their usage needs to be carefully hardened to avoid any security attacks on
> the guest, that's why we want to limit this interaction only to a small set
> of hardened drivers. For MMIO, the set is currently only virtio and MSI-X.
Good material for the commit log next time around. Thanks!
Bjorn
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-08-24 20:31 ` Bjorn Helgaas
@ 2021-08-24 20:50 ` Andi Kleen
2021-08-24 21:05 ` Dan Williams
2021-08-25 14:52 ` Bjorn Helgaas
0 siblings, 2 replies; 33+ messages in thread
From: Andi Kleen @ 2021-08-24 20:50 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Michael S. Tsirkin, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Rajat Jain, Thomas Gleixner, linux-arch, Jonathan Corbet,
Helge Deller, X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck,
Borislav Petkov, Andy Lutomirski, Bjorn Helgaas, Dan Williams,
virtualization, Richard Henderson, Thomas Bogendoerfer,
linux-parisc, Sean Christopherson, Linux Doc Mailing List,
Linux Kernel Mailing List, linux-alpha, David S . Miller,
Kirill Shutemov
On 8/24/2021 1:31 PM, Bjorn Helgaas wrote:
> On Tue, Aug 24, 2021 at 01:14:02PM -0700, Andi Kleen wrote:
>> On 8/24/2021 11:55 AM, Bjorn Helgaas wrote:
>>> [+cc Rajat; I still don't know what "shared memory with a hypervisor
>>> in a confidential guest" means,
>> A confidential guest is a guest which uses memory encryption to isolate
>> itself from the host. It doesn't trust the host. But it still needs to
>> communicate with the host for IO, so it has some special memory areas that
>> are explicitly marked shared. These are used to do IO with the host. All
>> their usage needs to be carefully hardened to avoid any security attacks on
>> the guest, that's why we want to limit this interaction only to a small set
>> of hardened drivers. For MMIO, the set is currently only virtio and MSI-X.
> Good material for the commit log next time around. Thanks!
This is all in the patch intro too, which should make it into the merge
commits.
I don't think we can reexplain the basic concepts for every individual
patch in a large patch kit.
-Andi
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-08-24 20:50 ` Andi Kleen
@ 2021-08-24 21:05 ` Dan Williams
2021-08-25 14:52 ` Bjorn Helgaas
1 sibling, 0 replies; 33+ messages in thread
From: Dan Williams @ 2021-08-24 21:05 UTC (permalink / raw)
To: Andi Kleen
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Michael S. Tsirkin, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Rajat Jain, linux-arch, Jonathan Corbet, Helge Deller, X86 ML,
Ingo Molnar, Bjorn Helgaas, Arnd Bergmann, Tony Luck,
Borislav Petkov, Andy Lutomirski, Bjorn Helgaas, Thomas Gleixner,
virtualization, Richard Henderson, Thomas Bogendoerfer,
linux-parisc, Sean Christopherson, Linux Doc Mailing List,
Linux Kernel Mailing List, linux-alpha, David S . Miller,
Kirill Shutemov
On Tue, Aug 24, 2021 at 1:50 PM Andi Kleen <ak@linux.intel.com> wrote:
>
>
> On 8/24/2021 1:31 PM, Bjorn Helgaas wrote:
> > On Tue, Aug 24, 2021 at 01:14:02PM -0700, Andi Kleen wrote:
> >> On 8/24/2021 11:55 AM, Bjorn Helgaas wrote:
> >>> [+cc Rajat; I still don't know what "shared memory with a hypervisor
> >>> in a confidential guest" means,
> >> A confidential guest is a guest which uses memory encryption to isolate
> >> itself from the host. It doesn't trust the host. But it still needs to
> >> communicate with the host for IO, so it has some special memory areas that
> >> are explicitly marked shared. These are used to do IO with the host. All
> >> their usage needs to be carefully hardened to avoid any security attacks on
> >> the guest, that's why we want to limit this interaction only to a small set
> >> of hardened drivers. For MMIO, the set is currently only virtio and MSI-X.
> > Good material for the commit log next time around. Thanks!
>
> This is all in the patch intro too, which should make it into the merge
> commits.
>
> I don't think we can reexplain the basic concepts for every individual
> patch in a large patch kit.
Maybe not the whole cover letter, but how about just a line in this
one that says "Recall that 'shared' in this context refers to memory
that lacks confidentiality and integrity protection from the VMM so
that it can communicate with the VM." Although I think
ioremap_noprotect() might be clearer than shared for the protected
guest use case?
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
[not found] ` <CACK8Z6E+__kZqU8mVUnYhFc0wz_e81qBLO3ffqSDghVtztNeQw@mail.gmail.com>
@ 2021-08-24 21:59 ` Dan Williams
0 siblings, 0 replies; 33+ messages in thread
From: Dan Williams @ 2021-08-24 21:59 UTC (permalink / raw)
To: Rajat Jain
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Michael S. Tsirkin, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
linux-arch, Andi Kleen, Jonathan Corbet, Helge Deller, X86 ML,
Ingo Molnar, Arnd Bergmann, Tony Luck, Borislav Petkov,
Andy Lutomirski, Bjorn Helgaas, Thomas Gleixner, virtualization,
Richard Henderson, Thomas Bogendoerfer, linux-parisc,
Sean Christopherson, Linux Doc Mailing List,
Linux Kernel Mailing List, linux-alpha, David S . Miller,
Kirill Shutemov
On Tue, Aug 24, 2021 at 2:57 PM Rajat Jain <rajatja@google.com> wrote:
>
> On Mon, Aug 23, 2021 at 6:06 PM Dan Williams <dan.j.williams@intel.com> wrote:
> >
> > On Mon, Aug 23, 2021 at 5:31 PM Kuppuswamy, Sathyanarayanan
> > <sathyanarayanan.kuppuswamy@linux.intel.com> 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<ak@linux.intel.com>
> > > >> Signed-off-by: Kuppuswamy Sathyanarayanan<sathyanarayanan.kuppuswamy@linux.intel.com>
> > > > 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.
> >
> > Note, I specifically said "unaudited", not "hardened" because as Greg
> > mentioned the kernel must trust drivers, its devices that may not be
> > trusted.
>
> Can you please point me to the thread where this discussion with Greg
> is ongoing?
It slowed down to implement the "move to the 'authorized' device
model" recommendation. LWN has a good writeup (as usual) and a link to
the thread:
https://lwn.net/Articles/865918/
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-08-24 20:50 ` Andi Kleen
2021-08-24 21:05 ` Dan Williams
@ 2021-08-25 14:52 ` Bjorn Helgaas
1 sibling, 0 replies; 33+ messages in thread
From: Bjorn Helgaas @ 2021-08-25 14:52 UTC (permalink / raw)
To: Andi Kleen
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Michael S. Tsirkin, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Rajat Jain, Thomas Gleixner, linux-arch, Jonathan Corbet,
Helge Deller, X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck,
Borislav Petkov, Andy Lutomirski, Bjorn Helgaas, Dan Williams,
virtualization, Richard Henderson, Thomas Bogendoerfer,
linux-parisc, Sean Christopherson, Linux Doc Mailing List,
Linux Kernel Mailing List, linux-alpha, David S . Miller,
Kirill Shutemov
On Tue, Aug 24, 2021 at 01:50:00PM -0700, Andi Kleen wrote:
>
> On 8/24/2021 1:31 PM, Bjorn Helgaas wrote:
> > On Tue, Aug 24, 2021 at 01:14:02PM -0700, Andi Kleen wrote:
> > > On 8/24/2021 11:55 AM, Bjorn Helgaas wrote:
> > > > [+cc Rajat; I still don't know what "shared memory with a hypervisor
> > > > in a confidential guest" means,
> > > A confidential guest is a guest which uses memory encryption to isolate
> > > itself from the host. It doesn't trust the host. But it still needs to
> > > communicate with the host for IO, so it has some special memory areas that
> > > are explicitly marked shared. These are used to do IO with the host. All
> > > their usage needs to be carefully hardened to avoid any security attacks on
> > > the guest, that's why we want to limit this interaction only to a small set
> > > of hardened drivers. For MMIO, the set is currently only virtio and MSI-X.
> > Good material for the commit log next time around. Thanks!
>
> This is all in the patch intro too, which should make it into the merge
> commits.
It's good if the cover letter makes into the merge commit log.
It's probably just because my git foo is lacking, but merge commit
logs don't seem as discoverable as the actual patch commit logs. Five
years from now, if I want to learn about pci_iomap_shared() history, I
would "git log -p lib/pci_iomap.c" and search for it. But I don't
think I would see the merge commit then.
Bjorn
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-08-24 17:20 ` Andi Kleen
2021-08-24 18:55 ` Bjorn Helgaas
@ 2021-08-29 15:27 ` Michael S. Tsirkin
2021-08-29 16:17 ` Andi Kleen
1 sibling, 1 reply; 33+ messages in thread
From: Michael S. Tsirkin @ 2021-08-29 15:27 UTC (permalink / raw)
To: Andi Kleen
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Linux Doc Mailing List, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Thomas Gleixner, linux-arch, Jonathan Corbet, Helge Deller,
X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck, Borislav Petkov,
Andy Lutomirski, Bjorn Helgaas, Dan Williams, virtualization,
Richard Henderson, Thomas Bogendoerfer, linux-parisc,
Sean Christopherson, Linux Kernel Mailing List, linux-alpha,
David S . Miller, Kirill Shutemov
On Tue, Aug 24, 2021 at 10:20:44AM -0700, Andi Kleen wrote:
>
> > 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.
>
> That concept exists too. There is a separate allow list for the drivers. So
> just adding shared to a driver is not enough, until it's also added to the
> allowlist
>
> Users can of course chose to disable the allowlist, but they need to
> understand the security implications.
Right. So given that, why do we need to tweak a random API like the map?
If you just make all maps be shared then the user is in control.
Seems sensible to me.
>
> >
> > I would say an explicit flag in the driver that says "hardened"
> > and refusing to init a non hardened one would be better.
>
>
> We have that too (that's the device filtering)
>
> But the problem is that device filtering just stops the probe functions, not
> the initcalls, and lot of legacy drivers do MMIO interactions before going
> into probe. In some cases it's unavoidable because of the device doesn't
> have a separate enumeration mechanism it needs some kind of probing to even
> check for its existence And since we don't want to change all of them it's
> far safer to make the ioremap opt-in.
>
>
> -Andi
Let's be frank, even without encryption disabling most drivers -
especially weird ones that poke at hardware before probe -
is far safer than keeping them, but one loses a bunch of features.
IOW all this hardening is nice but which security/feature tradeoff
to take it a policy decision, not something kernel should do
imho.
--
MST
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-08-24 17:04 ` Andi Kleen
@ 2021-08-29 15:34 ` Michael S. Tsirkin
2021-08-29 16:43 ` Andi Kleen
0 siblings, 1 reply; 33+ messages in thread
From: Michael S. Tsirkin @ 2021-08-29 15:34 UTC (permalink / raw)
To: Andi Kleen
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
linux-doc, Peter Zijlstra, linux-pci, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Thomas Gleixner, linux-arch, Jonathan Corbet, Helge Deller, x86,
Christoph Hellwig, Ingo Molnar, Arnd Bergmann, Tony Luck,
Borislav Petkov, Andy Lutomirski, Bjorn Helgaas, Dan Williams,
virtualization, Richard Henderson, Thomas Bogendoerfer,
linux-parisc, Sean Christopherson, linux-kernel, linux-alpha,
David S . Miller, Kirill Shutemov
On Tue, Aug 24, 2021 at 10:04:26AM -0700, Andi Kleen wrote:
>
> On 8/24/2021 12:07 AM, Christoph Hellwig wrote:
> > On Mon, Aug 23, 2021 at 05:30:54PM -0700, 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<ak@linux.intel.com>
> > > > > Signed-off-by: Kuppuswamy Sathyanarayanan<sathyanarayanan.kuppuswamy@linux.intel.com>
> > > > 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.
> > Well, assuming the host can do any damage when mapped shared that also
> > means not mapping it shared will completely break the drivers.
>
> There are several cases:
>
> - We have driver filtering active to protect you against attacks from the
> host against unhardened drivers.
>
> In this case the drivers not working is the intended behavior.
>
> - There is an command allow list override for some new driver, but the
> driver is hardened and shared
>
> The other drivers will still not work, but that's also the intended behavior
>
> - Driver filtering is disabled or the allow list override is used to enable
> some non hardened/enabled driver
>
> There is a command line option to override the ioremap sharing default, it
> will allow all drivers to do ioremap. We would really prefer to make it more
> finegrained, but it's not possible in this case. Other drivers are likely
> attackable.
>
> - Driver filtering is disabled (allowing attacks on the drivers) and the
> command line option for forced sharing is set.
>
> All drivers initialize and can talk to the host through MMIO. Lots of
> unhardened drivers are likely attackable.
>
> -Andi
All this makes sense but ioremap is such a random place to declare
driver has been audited, and it's baked into the binary with no way for
userspace to set policy.
Again all we will end up with is gradual replacement of all ioremap
calls with ioremap_shared as people discover a given driver does not
work in a VM. How are you going to know driver has actually been
audited? what the quality of the audit was? did the people doing the
auditing understand what they are auditing for? No way, right?
So IMHO, let it be for now.
--
MST
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-08-29 15:27 ` Michael S. Tsirkin
@ 2021-08-29 16:17 ` Andi Kleen
2021-08-29 22:26 ` Michael S. Tsirkin
0 siblings, 1 reply; 33+ messages in thread
From: Andi Kleen @ 2021-08-29 16:17 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Linux Doc Mailing List, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Thomas Gleixner, linux-arch, Jonathan Corbet, Helge Deller,
X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck, Borislav Petkov,
Andy Lutomirski, Bjorn Helgaas, Dan Williams, virtualization,
Richard Henderson, Thomas Bogendoerfer, linux-parisc,
Sean Christopherson, Linux Kernel Mailing List, linux-alpha,
David S . Miller, Kirill Shutemov
> Let's be frank, even without encryption disabling most drivers -
> especially weird ones that poke at hardware before probe -
> is far safer than keeping them, but one loses a bunch of features.
Usually we don't lose features at all. None of the legacy drivers are
needed on a guest (or even a modern native system). It's all just all
for old hardware. Maybe in 20+ years it can be all removed, but we can't
wait that long.
> IOW all this hardening is nice but which security/feature tradeoff
> to take it a policy decision, not something kernel should do
> imho.
There's no mechanism to push this kind of policy to user space. Users
don't have control what initcalls run. At the time they execute there
isn't even any user space yet.
Even if they could somehow control them it's very unlikely they would
understand them and make an informed decision.
Doing it at build time is not feasible either since we want to run on
standard distribution kernels.
For modules we have a policy mechanism (prevent udev probing by
preventing enumeration), and that is implemented, but only handling
modules is not enough. The compiled in drivers have to be handled too,
otherwise you have gaping holes in the protection. We don't prevent
users manually loading modules that might probe, but that is a policy
decision that users actually sensibly make in user space.
Also I changing this single call really that bad? It's not that we
changing anything drastic here, just give the low level subsystem a
better hint about the intention. If you don't like the function name,
could make it an argument instead?
-Andi
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-08-29 15:34 ` Michael S. Tsirkin
@ 2021-08-29 16:43 ` Andi Kleen
0 siblings, 0 replies; 33+ messages in thread
From: Andi Kleen @ 2021-08-29 16:43 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
linux-doc, Peter Zijlstra, linux-pci, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Thomas Gleixner, linux-arch, Jonathan Corbet, Helge Deller, x86,
Christoph Hellwig, Ingo Molnar, Arnd Bergmann, Tony Luck,
Borislav Petkov, Andy Lutomirski, Bjorn Helgaas, Dan Williams,
virtualization, Richard Henderson, Thomas Bogendoerfer,
linux-parisc, Sean Christopherson, linux-kernel, linux-alpha,
David S . Miller, Kirill Shutemov
> All this makes sense but ioremap is such a random place to declare
> driver has been audited, and it's baked into the binary with no way for
> userspace to set policy.
>
> Again all we will end up with is gradual replacement of all ioremap
> calls with ioremap_shared as people discover a given driver does not
> work in a VM.
No the device filter will prevent that. They would need to submit
patches to the central list.
Or they can override it at the command line, but there is already an
option to force all ioremaps to be shared. So if you just want some
driver to run without caring about security you can already do that
without modifying it.
Besides the shared concept only makes sense for virtual devices, so if
you don't have a device model for a device this will never happen either.
So I don't think your scenario of all ioremaps becoming shared will ever
happen.
> How are you going to know driver has actually been
> audited? what the quality of the audit was? did the people doing the
> auditing understand what they are auditing for? No way, right?
First the primary purpose of the ioremap policy is to avoid messing with
all the legacy drivers (which is 99+% of the code base)
How to handle someone maliciously submitting a driver to the kernel is a
completely different problem. To some degree there is trust of course.
If someone says they audited and a maintainer trusts them with their
statement, but they actually didn't there is a problem, but it's larger
than just TDX. But in such a case the community code audit will also
focus on such areas, and people interested in confidential computing
security will also start taking a look.
And we're also working on fuzzing, so these drivers will be fuzzed at
some point, so mistakes will be eventually found.
But in any case the ioremap policy is mainly to prevent having to handle
this for all legacy drivers.
I would rather change the few drivers that are actually needed, than all
the other drivers.
That's really the fundamental problem this is addressing: how to get
reasonable security with all the legacy drivers out of the box without
touching them.
-Andi
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-08-29 16:17 ` Andi Kleen
@ 2021-08-29 22:26 ` Michael S. Tsirkin
2021-08-30 5:11 ` Andi Kleen
0 siblings, 1 reply; 33+ messages in thread
From: Michael S. Tsirkin @ 2021-08-29 22:26 UTC (permalink / raw)
To: Andi Kleen
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Linux Doc Mailing List, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Thomas Gleixner, linux-arch, Jonathan Corbet, Helge Deller,
X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck, Borislav Petkov,
Andy Lutomirski, Bjorn Helgaas, Dan Williams, virtualization,
Richard Henderson, Thomas Bogendoerfer, linux-parisc,
Sean Christopherson, Linux Kernel Mailing List, linux-alpha,
David S . Miller, Kirill Shutemov
On Sun, Aug 29, 2021 at 09:17:53AM -0700, Andi Kleen wrote:
> Also I changing this single call really that bad? It's not that we changing
> anything drastic here, just give the low level subsystem a better hint about
> the intention. If you don't like the function name, could make it an
> argument instead?
My point however is that the API should say that the
driver has been audited, not that the mapping has been
done in some special way. For example the mapping can be
in some kind of wrapper, not directly in the driver.
However you want the driver validated, not the wrapper.
Here's an idea:
diff --git a/include/linux/audited.h b/include/linux/audited.h
new file mode 100644
index 000000000000..e23fd6ad50db
--- /dev/null
+++ b/include/linux/audited.h
@@ -0,0 +1,3 @@
+#ifndef AUDITED_MODULE
+#define AUDITED_MODULE
+#endif
Now any audited driver must do
#include <linux/audited.h>
first of all.
Implementation-wise it can do any number of things,
e.g. if you like then sure you can do:
#ifdef AUDITED_MODULE
#define pci_ioremap pci_ioremap_shared
#else
#define pci_ioremap pci_ioremap
#endif
but you can also thinkably do something like (won't work,
but just to give you the idea):
#ifdef AUDITED_MODULE
#define __init __init
#else
#define __init
#endif
or any number of hacks like this.
--
MST
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply related [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-08-29 22:26 ` Michael S. Tsirkin
@ 2021-08-30 5:11 ` Andi Kleen
2021-08-30 20:59 ` Michael S. Tsirkin
0 siblings, 1 reply; 33+ messages in thread
From: Andi Kleen @ 2021-08-30 5:11 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Linux Doc Mailing List, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Thomas Gleixner, linux-arch, Jonathan Corbet, Helge Deller,
X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck, Borislav Petkov,
Andy Lutomirski, Bjorn Helgaas, Dan Williams, virtualization,
Richard Henderson, Thomas Bogendoerfer, linux-parisc,
Sean Christopherson, Linux Kernel Mailing List, linux-alpha,
David S . Miller, Kirill Shutemov
On 8/29/2021 3:26 PM, Michael S. Tsirkin wrote:
> On Sun, Aug 29, 2021 at 09:17:53AM -0700, Andi Kleen wrote:
>> Also I changing this single call really that bad? It's not that we changing
>> anything drastic here, just give the low level subsystem a better hint about
>> the intention. If you don't like the function name, could make it an
>> argument instead?
> My point however is that the API should say that the
> driver has been audited,
We have that status in the struct device. If you want to tie the ioremap
to that we could define a ioremap_device() with a device argument and
decide based on that.
Or we can add _audited to the name. ioremap_shared_audited?
> not that the mapping has been
> done in some special way. For example the mapping can be
> in some kind of wrapper, not directly in the driver.
> However you want the driver validated, not the wrapper.
>
> Here's an idea:
I don't think magic differences of API behavior based on some define are
a good idea. That's easy to miss.
That's a "COME FROM" in API design.
Also it wouldn't handle the case that a driver has both private and
shared ioremaps, e.g. for BIOS structures.
And we've been avoiding that drivers can self declare auditing, we've
been trying to have a separate centralized list so that it's easier to
enforce and avoids any cut'n'paste mistakes.
-Andi
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-08-30 5:11 ` Andi Kleen
@ 2021-08-30 20:59 ` Michael S. Tsirkin
2021-08-31 0:23 ` Andi Kleen
0 siblings, 1 reply; 33+ messages in thread
From: Michael S. Tsirkin @ 2021-08-30 20:59 UTC (permalink / raw)
To: Andi Kleen
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Linux Doc Mailing List, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Thomas Gleixner, linux-arch, Jonathan Corbet, Helge Deller,
X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck, Borislav Petkov,
Andy Lutomirski, Bjorn Helgaas, Dan Williams, virtualization,
Richard Henderson, Thomas Bogendoerfer, linux-parisc,
Sean Christopherson, Linux Kernel Mailing List, linux-alpha,
David S . Miller, Kirill Shutemov
On Sun, Aug 29, 2021 at 10:11:46PM -0700, Andi Kleen wrote:
>
> On 8/29/2021 3:26 PM, Michael S. Tsirkin wrote:
> > On Sun, Aug 29, 2021 at 09:17:53AM -0700, Andi Kleen wrote:
> > > Also I changing this single call really that bad? It's not that we changing
> > > anything drastic here, just give the low level subsystem a better hint about
> > > the intention. If you don't like the function name, could make it an
> > > argument instead?
> > My point however is that the API should say that the
> > driver has been audited,
>
> We have that status in the struct device. If you want to tie the ioremap to
> that we could define a ioremap_device() with a device argument and decide
> based on that.
But it's not the device that is audited. And it's not the device
that might be secure or insecure. It's the driver.
> Or we can add _audited to the name. ioremap_shared_audited?
But it's not the mapping that has to be done in handled special way.
It's any data we get from device, not all of it coming from IO, e.g.
there's DMA and interrupts that all have to be validated.
Wouldn't you say that what is really wanted is just not running
unaudited drivers in the first place?
>
> > not that the mapping has been
> > done in some special way. For example the mapping can be
> > in some kind of wrapper, not directly in the driver.
> > However you want the driver validated, not the wrapper.
> >
> > Here's an idea:
>
>
> I don't think magic differences of API behavior based on some define are a
> good idea. That's easy to miss.
Well ... my point is that actually there is no difference in API
behaviour. the map is the same map, exactly same data goes to device. If
anything any non-shared map is special in that encrypted data goes to
device.
>
> That's a "COME FROM" in API design.
>
> Also it wouldn't handle the case that a driver has both private and shared
> ioremaps, e.g. for BIOS structures.
Hmm. Interesting. It's bios maps that are unusual and need to be private though ...
> And we've been avoiding that drivers can self declare auditing, we've been
> trying to have a separate centralized list so that it's easier to enforce
> and avoids any cut'n'paste mistakes.
>
> -Andi
Now I'm confused. What is proposed here seems to be basically that,
drivers need to declare auditing by replacing ioremap with
ioremap_shared.
--
MST
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-08-30 20:59 ` Michael S. Tsirkin
@ 2021-08-31 0:23 ` Andi Kleen
2021-09-10 9:54 ` Michael S. Tsirkin
0 siblings, 1 reply; 33+ messages in thread
From: Andi Kleen @ 2021-08-31 0:23 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Linux Doc Mailing List, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Thomas Gleixner, linux-arch, Jonathan Corbet, Helge Deller,
X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck, Borislav Petkov,
Andy Lutomirski, Bjorn Helgaas, Dan Williams, virtualization,
Richard Henderson, Thomas Bogendoerfer, linux-parisc,
Sean Christopherson, Linux Kernel Mailing List, linux-alpha,
David S . Miller, Kirill Shutemov
On 8/30/2021 1:59 PM, Michael S. Tsirkin wrote:
>
>> Or we can add _audited to the name. ioremap_shared_audited?
> But it's not the mapping that has to be done in handled special way.
> It's any data we get from device, not all of it coming from IO, e.g.
> there's DMA and interrupts that all have to be validated.
> Wouldn't you say that what is really wanted is just not running
> unaudited drivers in the first place?
Yes.
>
>> And we've been avoiding that drivers can self declare auditing, we've been
>> trying to have a separate centralized list so that it's easier to enforce
>> and avoids any cut'n'paste mistakes.
>>
>> -Andi
> Now I'm confused. What is proposed here seems to be basically that,
> drivers need to declare auditing by replacing ioremap with
> ioremap_shared.
Auditing is declared on the device model level using a central allow list.
But this cannot do anything to initcalls that run before probe, that's
why an extra level of defense of ioremap opt-in is useful. But it's not
the primary mechanism to declare a driver audited, that's the allow
list. The ioremap is just another mechanism to avoid having to touch a
lot of legacy drivers.
If we agree on that then the original proposed semantics of
"ioremap_shared" may be acceptable?
-Andi
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-08-31 0:23 ` Andi Kleen
@ 2021-09-10 9:54 ` Michael S. Tsirkin
2021-09-10 16:34 ` Andi Kleen
0 siblings, 1 reply; 33+ messages in thread
From: Michael S. Tsirkin @ 2021-09-10 9:54 UTC (permalink / raw)
To: Andi Kleen
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Linux Doc Mailing List, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Thomas Gleixner, linux-arch, Jonathan Corbet, Helge Deller,
X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck, Borislav Petkov,
Andy Lutomirski, Bjorn Helgaas, Dan Williams, virtualization,
Richard Henderson, Thomas Bogendoerfer, linux-parisc,
Sean Christopherson, Linux Kernel Mailing List, linux-alpha,
David S . Miller, Kirill Shutemov
On Mon, Aug 30, 2021 at 05:23:17PM -0700, Andi Kleen wrote:
>
> On 8/30/2021 1:59 PM, Michael S. Tsirkin wrote:
> >
> > > Or we can add _audited to the name. ioremap_shared_audited?
> > But it's not the mapping that has to be done in handled special way.
> > It's any data we get from device, not all of it coming from IO, e.g.
> > there's DMA and interrupts that all have to be validated.
> > Wouldn't you say that what is really wanted is just not running
> > unaudited drivers in the first place?
>
>
> Yes.
Then ... let's do just that?
>
> >
> > > And we've been avoiding that drivers can self declare auditing, we've been
> > > trying to have a separate centralized list so that it's easier to enforce
> > > and avoids any cut'n'paste mistakes.
> > >
> > > -Andi
> > Now I'm confused. What is proposed here seems to be basically that,
> > drivers need to declare auditing by replacing ioremap with
> > ioremap_shared.
>
> Auditing is declared on the device model level using a central allow list.
Can we not have an init call allow list instead of, or in addition to, a
device allow list?
> But this cannot do anything to initcalls that run before probe,
Can't we extend module_init so init calls are validated against the
allow list?
> that's why
> an extra level of defense of ioremap opt-in is useful.
OK even assuming this, why is pci_iomap opt-in useful?
That never happens before probe - there's simply no pci_device then.
> But it's not the
> primary mechanism to declare a driver audited, that's the allow list. The
> ioremap is just another mechanism to avoid having to touch a lot of legacy
> drivers.
>
> If we agree on that then the original proposed semantics of "ioremap_shared"
> may be acceptable?
>
> -Andi
>
It looks suspiciously like drivers self-declaring auditing to me which
we both seem to agree is undesirable. What exactly is the difference?
Or are you just trying to disable anything that runs before probe?
In that case I don't see a reason to touch pci drivers though.
These should be fine with just the device model list.
--
MST
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-09-10 9:54 ` Michael S. Tsirkin
@ 2021-09-10 16:34 ` Andi Kleen
2021-09-11 23:54 ` Michael S. Tsirkin
0 siblings, 1 reply; 33+ messages in thread
From: Andi Kleen @ 2021-09-10 16:34 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Linux Doc Mailing List, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Thomas Gleixner, linux-arch, Jonathan Corbet, Helge Deller,
X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck, Borislav Petkov,
Andy Lutomirski, Bjorn Helgaas, Dan Williams, virtualization,
Richard Henderson, Thomas Bogendoerfer, linux-parisc,
Sean Christopherson, Linux Kernel Mailing List, linux-alpha,
David S . Miller, Kirill Shutemov
>>>> And we've been avoiding that drivers can self declare auditing, we've been
>>>> trying to have a separate centralized list so that it's easier to enforce
>>>> and avoids any cut'n'paste mistakes.
>>>>
>>>> -Andi
>>> Now I'm confused. What is proposed here seems to be basically that,
>>> drivers need to declare auditing by replacing ioremap with
>>> ioremap_shared.
>> Auditing is declared on the device model level using a central allow list.
> Can we not have an init call allow list instead of, or in addition to, a
> device allow list?
That would be quite complicated and intrusive. In fact I'm not even sure
how to do maintain something like this. There are a lot of needed
initcalls, they would all need to be marked. How can we distinguish
them? It would be a giant auditing project. And of course how would you
prevent it from bitrotting?
Basically it would be hundreds of changes all over the tree, just to
avoid two changes in virtio and MSI. Approach of just stopping the
initcalls from doing bad things is much less intrusive.
>
>> But this cannot do anything to initcalls that run before probe,
> Can't we extend module_init so init calls are validated against the
> allow list?
See above.
Also the problem isn't really with modules (we rely on udev not loading
them), but with builtin initcalls
>
>> that's why
>> an extra level of defense of ioremap opt-in is useful.
> OK even assuming this, why is pci_iomap opt-in useful?
> That never happens before probe - there's simply no pci_device then.
Hmm, yes that's true. I guess we can make it default to opt-in for
pci_iomap.
It only really matters for device less ioremaps.
>
> It looks suspiciously like drivers self-declaring auditing to me which
> we both seem to agree is undesirable. What exactly is the difference?
Just allow listing the ioremaps is not self declaration because the
device will still not initialize due to the central device filter. If
you want to use it that has to be changed.
It's just an additional safety net to contain code running before probe.
>
> Or are you just trying to disable anything that runs before probe?
Well anything that could do dangerous host interactions (like processing
ioremap data) A lot of things are harmless and can be allowed, or
already blocked elsewhere (e.g. we have a IO port filter). This just
handles the ioremap/MMIO case.
> In that case I don't see a reason to touch pci drivers though.
> These should be fine with just the device model list.
That won't stop initcalls.
-Andi
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-09-10 16:34 ` Andi Kleen
@ 2021-09-11 23:54 ` Michael S. Tsirkin
2021-09-13 5:53 ` Michael S. Tsirkin
2021-09-24 22:43 ` Andi Kleen
0 siblings, 2 replies; 33+ messages in thread
From: Michael S. Tsirkin @ 2021-09-11 23:54 UTC (permalink / raw)
To: Andi Kleen
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Linux Doc Mailing List, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Thomas Gleixner, linux-arch, Jonathan Corbet, Helge Deller,
X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck, Borislav Petkov,
Andy Lutomirski, Bjorn Helgaas, Dan Williams, virtualization,
Richard Henderson, Thomas Bogendoerfer, linux-parisc,
Sean Christopherson, Linux Kernel Mailing List, linux-alpha,
David S . Miller, Kirill Shutemov
On Fri, Sep 10, 2021 at 09:34:45AM -0700, Andi Kleen wrote:
> > > that's why
> > > an extra level of defense of ioremap opt-in is useful.
> > OK even assuming this, why is pci_iomap opt-in useful?
> > That never happens before probe - there's simply no pci_device then.
>
>
> Hmm, yes that's true. I guess we can make it default to opt-in for
> pci_iomap.
>
> It only really matters for device less ioremaps.
OK. And same thing for other things with device, such as
devm_platform_ioremap_resource.
If we agree on all that, this will basically remove virtio
changes from the picture ;)
--
MST
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-09-11 23:54 ` Michael S. Tsirkin
@ 2021-09-13 5:53 ` Michael S. Tsirkin
2021-09-24 22:43 ` Andi Kleen
1 sibling, 0 replies; 33+ messages in thread
From: Michael S. Tsirkin @ 2021-09-13 5:53 UTC (permalink / raw)
To: Andi Kleen
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Linux Doc Mailing List, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Thomas Gleixner, linux-arch, Jonathan Corbet, Helge Deller,
X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck, Borislav Petkov,
Andy Lutomirski, Bjorn Helgaas, Dan Williams, virtualization,
Richard Henderson, Thomas Bogendoerfer, linux-parisc,
Sean Christopherson, Linux Kernel Mailing List, linux-alpha,
David S . Miller, Kirill Shutemov
On Sat, Sep 11, 2021 at 07:54:43PM -0400, Michael S. Tsirkin wrote:
> On Fri, Sep 10, 2021 at 09:34:45AM -0700, Andi Kleen wrote:
> > > > that's why
> > > > an extra level of defense of ioremap opt-in is useful.
> > > OK even assuming this, why is pci_iomap opt-in useful?
> > > That never happens before probe - there's simply no pci_device then.
> >
> >
> > Hmm, yes that's true. I guess we can make it default to opt-in for
> > pci_iomap.
> >
> > It only really matters for device less ioremaps.
>
> OK. And same thing for other things with device, such as
> devm_platform_ioremap_resource.
> If we agree on all that, this will basically remove virtio
> changes from the picture ;)
Something else that was pointed out to me:
fs->window_kaddr = devm_memremap_pages(&vdev->dev, pgmap);
if (IS_ERR(fs->window_kaddr))
return PTR_ERR(fs->window_kaddr);
looks like if we forget to set the shared flag then it will
corrupt the DAX data?
> --
> MST
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-09-11 23:54 ` Michael S. Tsirkin
2021-09-13 5:53 ` Michael S. Tsirkin
@ 2021-09-24 22:43 ` Andi Kleen
2021-09-27 9:07 ` Michael S. Tsirkin
1 sibling, 1 reply; 33+ messages in thread
From: Andi Kleen @ 2021-09-24 22:43 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Linux Doc Mailing List, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Thomas Gleixner, linux-arch, Jonathan Corbet, Helge Deller,
X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck, Borislav Petkov,
Andy Lutomirski, Bjorn Helgaas, Dan Williams, virtualization,
Richard Henderson, Thomas Bogendoerfer, linux-parisc,
Sean Christopherson, Linux Kernel Mailing List, linux-alpha,
David S . Miller, Kirill Shutemov
>> Hmm, yes that's true. I guess we can make it default to opt-in for
>> pci_iomap.
>>
>> It only really matters for device less ioremaps.
> OK. And same thing for other things with device, such as
> devm_platform_ioremap_resource.
> If we agree on all that, this will basically remove virtio
> changes from the picture ;)
Hi we revisited this now. One problem with removing the ioremap opt-in
is that it's still possible for drivers to get at devices without going
through probe. For example they can walk the PCI device list. Some
drivers do that for various reasons. So if we remove the opt-in we would
need to audit and possibly fix all that, which would be potentially a
lot of churn. That's why I think it's better to keep the opt-in.
-Andi
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range}
2021-09-24 22:43 ` Andi Kleen
@ 2021-09-27 9:07 ` Michael S. Tsirkin
0 siblings, 0 replies; 33+ messages in thread
From: Michael S. Tsirkin @ 2021-09-27 9:07 UTC (permalink / raw)
To: Andi Kleen
Cc: Kuppuswamy, Sathyanarayanan, Kuppuswamy Sathyanarayanan,
Linux Doc Mailing List, Peter Zijlstra, Linux PCI, linux-mips,
James E J Bottomley, Dave Hansen, Peter H Anvin, sparclinux,
Thomas Gleixner, linux-arch, Jonathan Corbet, Helge Deller,
X86 ML, Ingo Molnar, Arnd Bergmann, Tony Luck, Borislav Petkov,
Andy Lutomirski, Bjorn Helgaas, Dan Williams, virtualization,
Richard Henderson, Thomas Bogendoerfer, linux-parisc,
Sean Christopherson, Linux Kernel Mailing List, linux-alpha,
David S . Miller, Kirill Shutemov
On Fri, Sep 24, 2021 at 03:43:40PM -0700, Andi Kleen wrote:
>
> > > Hmm, yes that's true. I guess we can make it default to opt-in for
> > > pci_iomap.
> > >
> > > It only really matters for device less ioremaps.
> > OK. And same thing for other things with device, such as
> > devm_platform_ioremap_resource.
> > If we agree on all that, this will basically remove virtio
> > changes from the picture ;)
>
> Hi we revisited this now. One problem with removing the ioremap opt-in is
> that it's still possible for drivers to get at devices without going through
> probe. For example they can walk the PCI device list. Some drivers do that
> for various reasons. So if we remove the opt-in we would need to audit and
> possibly fix all that, which would be potentially a lot of churn. That's why
> I think it's better to keep the opt-in.
>
>
> -Andi
>
I've been thinking about why this still feels wrong to me.
Here's what I came up with: at some point someone will want one of these
modules (poking at devices in the initcall) in the encrypted
environment, and will change ioremap to ioremap_shared.
At that point the allowlist will be broken again, and
by that time it will be set in stone and too late to fix.
Isn't the problem that what is actually audited is modules,
but you are trying to add devices to allow list?
So why not have modules/initcalls in the allowlist then?
For built-in modules, we already have initcall_blacklisted, right?
This could be an extension ... no?
--
MST
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 33+ messages in thread
end of thread, other threads:[~2021-09-27 9:07 UTC | newest]
Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20210805005218.2912076-1-sathyanarayanan.kuppuswamy@linux.intel.com>
[not found] ` <20210805005218.2912076-11-sathyanarayanan.kuppuswamy@linux.intel.com>
2021-08-12 19:46 ` [PATCH v4 10/15] asm/io.h: Add ioremap_shared fallback Bjorn Helgaas
2021-08-13 7:58 ` Christoph Hellwig
[not found] ` <20210805005218.2912076-12-sathyanarayanan.kuppuswamy@linux.intel.com>
2021-08-13 8:02 ` [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range} Christoph Hellwig
2021-08-23 23:56 ` Michael S. Tsirkin
[not found] ` <26a3cce5-ddf7-cbe6-a41e-58a2aea48f78@linux.intel.com>
2021-08-24 1:04 ` Dan Williams
2021-08-24 2:14 ` Andi Kleen
2021-08-24 9:47 ` Michael S. Tsirkin
2021-08-24 17:20 ` Andi Kleen
2021-08-24 18:55 ` Bjorn Helgaas
2021-08-24 20:14 ` Andi Kleen
2021-08-24 20:31 ` Bjorn Helgaas
2021-08-24 20:50 ` Andi Kleen
2021-08-24 21:05 ` Dan Williams
2021-08-25 14:52 ` Bjorn Helgaas
2021-08-29 15:27 ` Michael S. Tsirkin
2021-08-29 16:17 ` Andi Kleen
2021-08-29 22:26 ` Michael S. Tsirkin
2021-08-30 5:11 ` Andi Kleen
2021-08-30 20:59 ` Michael S. Tsirkin
2021-08-31 0:23 ` Andi Kleen
2021-09-10 9:54 ` Michael S. Tsirkin
2021-09-10 16:34 ` Andi Kleen
2021-09-11 23:54 ` Michael S. Tsirkin
2021-09-13 5:53 ` Michael S. Tsirkin
2021-09-24 22:43 ` Andi Kleen
2021-09-27 9:07 ` Michael S. Tsirkin
[not found] ` <CACK8Z6E+__kZqU8mVUnYhFc0wz_e81qBLO3ffqSDghVtztNeQw@mail.gmail.com>
2021-08-24 21:59 ` Dan Williams
2021-08-24 7:07 ` Christoph Hellwig
2021-08-24 17:04 ` Andi Kleen
2021-08-29 15:34 ` Michael S. Tsirkin
2021-08-29 16:43 ` Andi Kleen
2021-08-24 9:12 ` Michael S. Tsirkin
[not found] ` <20210805005218.2912076-13-sathyanarayanan.kuppuswamy@linux.intel.com>
2021-08-13 8:07 ` [PATCH v4 12/15] pci: Mark MSI data shared Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).