[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220105003108.mr7zyd5oyaaxmnmv@box.shutemov.name>
Date: Wed, 5 Jan 2022 03:31:08 +0300
From: "Kirill A. Shutemov" <kirill@...temov.name>
To: Dave Hansen <dave.hansen@...el.com>
Cc: Borislav Petkov <bp@...en8.de>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Tom Lendacky <thomas.lendacky@....com>, tglx@...utronix.de,
mingo@...hat.com, luto@...nel.org, peterz@...radead.org,
sathyanarayanan.kuppuswamy@...ux.intel.com, aarcange@...hat.com,
ak@...ux.intel.com, dan.j.williams@...el.com, david@...hat.com,
hpa@...or.com, jgross@...e.com, jmattson@...gle.com,
joro@...tes.org, jpoimboe@...hat.com, knsathya@...nel.org,
pbonzini@...hat.com, sdeep@...are.com, seanjc@...gle.com,
tony.luck@...el.com, vkuznets@...hat.com, wanpengli@...cent.com,
x86@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 19/26] x86/tdx: Make pages shared in ioremap()
On Tue, Jan 04, 2022 at 12:36:06PM -0800, Dave Hansen wrote:
> On 1/4/22 11:14 AM, Kirill A. Shutemov wrote:
> > I see two possible options (I hate both): leave it defined in per-arch
> > <asm/pgtable.h> or move it to <linux/mm.h> next to user in
> > io_remap_pfn_range().
>
> Could we do an asm-generic/pgprot.h that was basically just:
>
> typedef struct { unsigned long pgprot; } pgprot_t;
>
> That would cover probably 80% of the of the architectures. The rest of
> them could define an actual asm/pgprot.h.
A file per typedef looks like an overkill.
Maybe <asm-generic/types.h> that included from <asm/types.h> would be
easier to justify. Some archs already have <asm/types.h>
Although, it is not as simple as your patches. See below.
>
> It doesn't seem to be *that* much work, although it is a bit of a shame
> that pgtable-types.h doesn't fix this already. I've attached something
> that compiles on s390 (representing a random non-x86 architecture) and x86.
> diff -puN arch/sparc/include/asm/page_32.h~pgprot-generic arch/sparc/include/asm/page_32.h
> --- a/arch/sparc/include/asm/page_32.h~pgprot-generic 2022-01-04 12:00:31.651180536 -0800
> +++ b/arch/sparc/include/asm/page_32.h 2022-01-04 12:00:31.659180446 -0800
> @@ -10,6 +10,7 @@
> #define _SPARC_PAGE_H
>
> #include <linux/const.h>
> +#include <asm-generic/pgprot.h>
>
> #define PAGE_SHIFT 12
> #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
> @@ -57,7 +58,6 @@ typedef struct { unsigned long iopte; }
> typedef struct { unsigned long pmd; } pmd_t;
> typedef struct { unsigned long pgd; } pgd_t;
> typedef struct { unsigned long ctxd; } ctxd_t;
> -typedef struct { unsigned long pgprot; } pgprot_t;
> typedef struct { unsigned long iopgprot; } iopgprot_t;
>
> #define pte_val(x) ((x).pte)
> @@ -85,7 +85,6 @@ typedef unsigned long iopte_t;
> typedef unsigned long pmd_t;
> typedef unsigned long pgd_t;
> typedef unsigned long ctxd_t;
> -typedef unsigned long pgprot_t;
> typedef unsigned long iopgprot_t;
>
> #define pte_val(x) (x)
Any arch that use STRICT_MM_TYPECHECKS hacks will get broken if compiled
without the define (as sparc by default).
It's fixable with more crunch (and more build bugs). I think we can use
approach from posix_types.h where asm-generic version defines the type if
it was not defined by the arch code.
Is it the way to go we want?
--
Kirill A. Shutemov
Powered by blists - more mailing lists