RE: [PATCH] btrfs: Disable BTRFS on platforms having 256K pages

2021-06-12 Thread Brian Cain



> -Original Message-
> From: Christophe Leroy 
...
> Le 10/06/2021 à 15:54, Chris Mason a écrit :
> >
> >> On Jun 10, 2021, at 1:23 AM, Christophe Leroy
>  wrote:
> >>
> >> With a config having PAGE_SIZE set to 256K, BTRFS build fails
> >> with the following message
> >>
> >> include/linux/compiler_types.h:326:38: error: call to
> '__compiletime_assert_791' declared with attribute error: BUILD_BUG_ON
> failed: (BTRFS_MAX_COMPRESSED % PAGE_SIZE) != 0
> >>
> >> BTRFS_MAX_COMPRESSED being 128K, BTRFS cannot support platforms
> with
> >> 256K pages at the time being.
> >>
> >> There are two platforms that can select 256K pages:
> >> - hexagon
> >> - powerpc
> >>
> >> Disable BTRFS when 256K page size is selected.
> >>
> >
> > We’ll have other subpage blocksize concerns with 256K pages, but this
> BTRFS_MAX_COMPRESSED #define is arbitrary.  It’s just trying to have an
> upper bound on the amount of memory we’ll need to uncompress a single
> page’s worth of random reads.
> >
> > We could change it to max(PAGE_SIZE, 128K) or just bump to 256K.
> >
> 
> But if 256K is problematic in other ways, is it worth bumping
> BTRFS_MAX_COMPRESSED to 256K ?
> 
> David, in below mail, said that 256K support would require deaper changes. So
> disabling BTRFS
> support seems the easiest solution for the time being, at least for Stable (I
> forgot the Fixes: tag
> and the CC: to stable).
> 
> On powerpc, 256k pages is a corner case, it requires customised binutils, so I
> don't think disabling
> BTRFS is a issue there. For hexagon I don't know.

Larger page sizes like this are typical for hexagon.  Disabling btrfs on 
hexagon seems appropriate.

-Brian



Re: [PATCH] usb: gadget: fsl: properly remove remnant of MXC support

2021-06-12 Thread Fabio Estevam
Hi Li,

On Fri, Jun 11, 2021 at 9:31 PM Li Yang  wrote:
>
> Commit a390bef7db1f ("usb: gadget: fsl_mxc_udc: Remove the driver")
> didn't remove all the MXC related stuff which can cause build problem
> for LS1021 when enabled again in Kconfig.  This patch remove all the
> remnants.
>
> Signed-off-by: Li Yang 

Thanks for the fix:

Reviewed-by: Fabio Estevam 


Re: [PATCH] usb: gadget: fsl: properly remove remnant of MXC support

2021-06-12 Thread Arnd Bergmann
On Sat, Jun 12, 2021 at 2:31 AM Li Yang  wrote:
>
> Commit a390bef7db1f ("usb: gadget: fsl_mxc_udc: Remove the driver")
> didn't remove all the MXC related stuff which can cause build problem
> for LS1021 when enabled again in Kconfig.  This patch remove all the
> remnants.
>
> Signed-off-by: Li Yang 

Looks good to me,

Acked-by: Arnd Bergmann 


Re: [PATCH v2 08/12] powerpc/32s: Allow disabling KUAP at boot time

2021-06-12 Thread Christophe Leroy




Le 03/06/2021 à 10:41, Christophe Leroy a écrit :

PPC64 uses MMU features to enable/disable KUAP at boot time.
But feature fixups are applied way too early on PPC32.

Now that all KUAP related actions are in C following the
conversion of KUAP initial setup and context switch in C,
static branches can be used to enable/disable KUAP.

Signed-off-by: Christophe Leroy 
---
  arch/powerpc/include/asm/book3s/32/kup.h | 27 +++-
  arch/powerpc/mm/book3s32/kuap.c  | 11 ++
  2 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/include/asm/book3s/32/kup.h 
b/arch/powerpc/include/asm/book3s/32/kup.h
index 2854d970dabe..68fbe28c6d7e 100644
--- a/arch/powerpc/include/asm/book3s/32/kup.h
+++ b/arch/powerpc/include/asm/book3s/32/kup.h
@@ -9,11 +9,12 @@
  
  #include 
  
+extern struct static_key_false disable_kuap_key;


Same as 8xx, this needs to be exported for modules.


  extern struct static_key_false disable_kuep_key;
  
  static __always_inline bool kuap_is_disabled(void)

  {
-   return !IS_ENABLED(CONFIG_PPC_KUAP);
+   return !IS_ENABLED(CONFIG_PPC_KUAP) || 
static_branch_unlikely(_kuap_key);
  }
  
  static __always_inline bool kuep_is_disabled(void)

@@ -62,6 +63,9 @@ static inline void kuap_save_and_lock(struct pt_regs *regs)
u32 addr = kuap & 0xf000;
u32 end = kuap << 28;
  
+	if (kuap_is_disabled())

+   return;
+
regs->kuap = kuap;
if (unlikely(!kuap))
return;
@@ -79,6 +83,9 @@ static inline void kuap_kernel_restore(struct pt_regs *regs, 
unsigned long kuap)
u32 addr = regs->kuap & 0xf000;
u32 end = regs->kuap << 28;
  
+	if (kuap_is_disabled())

+   return;
+
current->thread.kuap = regs->kuap;
  
  	if (unlikely(regs->kuap == kuap))

@@ -91,6 +98,9 @@ static inline unsigned long kuap_get_and_assert_locked(void)
  {
unsigned long kuap = current->thread.kuap;
  
+	if (kuap_is_disabled())

+   return 0;
+
WARN_ON_ONCE(IS_ENABLED(CONFIG_PPC_KUAP_DEBUG) && kuap != 0);
  
  	return kuap;

@@ -106,6 +116,9 @@ static __always_inline void allow_user_access(void __user 
*to, const void __user
  {
u32 addr, end;
  
+	if (kuap_is_disabled())

+   return;
+
BUILD_BUG_ON(!__builtin_constant_p(dir));
BUILD_BUG_ON(dir & ~KUAP_READ_WRITE);
  
@@ -128,6 +141,9 @@ static __always_inline void prevent_user_access(void __user *to, const void __us

  {
u32 addr, end;
  
+	if (kuap_is_disabled())

+   return;
+
BUILD_BUG_ON(!__builtin_constant_p(dir));
  
  	if (dir & KUAP_CURRENT_WRITE) {

@@ -159,6 +175,9 @@ static inline unsigned long prevent_user_access_return(void)
unsigned long end = flags << 28;
void __user *to = (__force void __user *)addr;
  
+	if (kuap_is_disabled())

+   return 0;
+
if (flags)
prevent_user_access(to, to, end - addr, KUAP_READ_WRITE);
  
@@ -171,6 +190,9 @@ static inline void restore_user_access(unsigned long flags)

unsigned long end = flags << 28;
void __user *to = (__force void __user *)addr;
  
+	if (kuap_is_disabled())

+   return;
+
if (flags)
allow_user_access(to, to, end - addr, KUAP_READ_WRITE);
  }
@@ -181,6 +203,9 @@ bad_kuap_fault(struct pt_regs *regs, unsigned long address, 
bool is_write)
unsigned long begin = regs->kuap & 0xf000;
unsigned long end = regs->kuap << 28;
  
+	if (kuap_is_disabled())

+   return false;
+
return is_write && (address < begin || address >= end);
  }
  
diff --git a/arch/powerpc/mm/book3s32/kuap.c b/arch/powerpc/mm/book3s32/kuap.c

index 5533ed92ab3d..a4ce6cdc28e5 100644
--- a/arch/powerpc/mm/book3s32/kuap.c
+++ b/arch/powerpc/mm/book3s32/kuap.c
@@ -3,15 +3,18 @@
  #include 
  #include 
  
+struct static_key_false disable_kuap_key;

+
  void __init setup_kuap(bool disabled)
  {
-   kuap_update_sr(mfsr(0) | SR_KS, 0, TASK_SIZE);
+   if (!disabled)
+   kuap_update_sr(mfsr(0) | SR_KS, 0, TASK_SIZE);
  
  	if (smp_processor_id() != boot_cpuid)

return;
  
-	pr_info("Activating Kernel Userspace Access Protection\n");

-
if (disabled)
-   pr_warn("KUAP cannot be disabled yet on 6xx when compiled 
in\n");
+   static_branch_enable(_kuap_key);
+   else
+   pr_info("Activating Kernel Userspace Access Protection\n");
  }