Merge tag 'asm-generic-unaligned-5.14' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 2 Jul 2021 19:43:40 +0000 (12:43 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 2 Jul 2021 19:43:40 +0000 (12:43 -0700)
Pull asm/unaligned.h unification from Arnd Bergmann:
 "Unify asm/unaligned.h around struct helper

  The get_unaligned()/put_unaligned() helpers are traditionally
  architecture specific, with the two main variants being the
  "access-ok.h" version that assumes unaligned pointer accesses always
  work on a particular architecture, and the "le-struct.h" version that
  casts the data to a byte aligned type before dereferencing, for
  architectures that cannot always do unaligned accesses in hardware.

  Based on the discussion linked below, it appears that the access-ok
  version is not realiable on any architecture, but the struct version
  probably has no downsides. This series changes the code to use the
  same implementation on all architectures, addressing the few
  exceptions separately"

Link: https://lore.kernel.org/lkml/75d07691-1e4f-741f-9852-38c0b4f520bc@synopsys.com/
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100363
Link: https://lore.kernel.org/lkml/20210507220813.365382-14-arnd@kernel.org/
Link: git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic.git unaligned-rework-v2
Link: https://lore.kernel.org/lkml/CAHk-=whGObOKruA_bU3aPGZfoDqZM1_9wBkwREp0H0FgR-90uQ@mail.gmail.com/
* tag 'asm-generic-unaligned-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic:
  asm-generic: simplify asm/unaligned.h
  asm-generic: uaccess: 1-byte access is always aligned
  netpoll: avoid put_unaligned() on single character
  mwifiex: re-fix for unaligned accesses
  apparmor: use get_unaligned() only for multi-byte words
  partitions: msdos: fix one-byte get_unaligned()
  asm-generic: unaligned always use struct helpers
  asm-generic: unaligned: remove byteshift helpers
  powerpc: use linux/unaligned/le_struct.h on LE power7
  m68k: select CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
  sh: remove unaligned access for sh4a
  openrisc: always use unaligned-struct header
  asm-generic: use asm-generic/unaligned.h for most architectures

1  2 
arch/m68k/Kconfig
block/partitions/msdos.c
net/core/netpoll.c

diff --combined arch/m68k/Kconfig
@@@ -21,6 -21,7 +21,7 @@@ config M68
        select HAVE_AOUT if MMU
        select HAVE_ASM_MODVERSIONS
        select HAVE_DEBUG_BUGVERBOSE
+       select HAVE_EFFICIENT_UNALIGNED_ACCESS if !CPU_HAS_NO_UNALIGNED
        select HAVE_FUTEX_CMPXCHG if MMU && FUTEX
        select HAVE_IDE
        select HAVE_MOD_ARCH_SPECIFIC
@@@ -34,7 -35,6 +35,7 @@@
        select SET_FS
        select UACCESS_MEMCPY if !MMU
        select VIRT_TO_BUS
 +      select ZONE_DMA
  
  config CPU_BIG_ENDIAN
        def_bool y
@@@ -63,6 -63,10 +64,6 @@@ config TIME_LOW_RE
  config NO_IOPORT_MAP
        def_bool y
  
 -config ZONE_DMA
 -      bool
 -      default y
 -
  config HZ
        int
        default 1000 if CLEOPATRA
diff --combined block/partitions/msdos.c
@@@ -38,8 -38,6 +38,6 @@@
   */
  #include <asm/unaligned.h>
  
- #define SYS_IND(p)    get_unaligned(&p->sys_ind)
  static inline sector_t nr_sects(struct msdos_partition *p)
  {
        return (sector_t)get_unaligned_le32(&p->nr_sects);
@@@ -52,9 -50,9 +50,9 @@@ static inline sector_t start_sect(struc
  
  static inline int is_extended_partition(struct msdos_partition *p)
  {
-       return (SYS_IND(p) == DOS_EXTENDED_PARTITION ||
-               SYS_IND(p) == WIN98_EXTENDED_PARTITION ||
-               SYS_IND(p) == LINUX_EXTENDED_PARTITION);
+       return (p->sys_ind == DOS_EXTENDED_PARTITION ||
+               p->sys_ind == WIN98_EXTENDED_PARTITION ||
+               p->sys_ind == LINUX_EXTENDED_PARTITION);
  }
  
  #define MSDOS_LABEL_MAGIC1    0x55
@@@ -193,7 -191,7 +191,7 @@@ static void parse_extended(struct parse
  
                        put_partition(state, state->next, next, size);
                        set_info(state, state->next, disksig);
-                       if (SYS_IND(p) == LINUX_RAID_PARTITION)
+                       if (p->sys_ind == LINUX_RAID_PARTITION)
                                state->parts[state->next].flags = ADDPART_FLAG_RAID;
                        loopct = 0;
                        if (++state->next == state->limit)
@@@ -546,7 -544,7 +544,7 @@@ static void parse_minix(struct parsed_p
         * a secondary MBR describing its subpartitions, or
         * the normal boot sector. */
        if (msdos_magic_present(data + 510) &&
-           SYS_IND(p) == MINIX_PARTITION) { /* subpartition table present */
+           p->sys_ind == MINIX_PARTITION) { /* subpartition table present */
                char tmp[1 + BDEVNAME_SIZE + 10 + 9 + 1];
  
                snprintf(tmp, sizeof(tmp), " %s%d: <minix:", state->name, origin);
                        if (state->next == state->limit)
                                break;
                        /* add each partition in use */
-                       if (SYS_IND(p) == MINIX_PARTITION)
+                       if (p->sys_ind == MINIX_PARTITION)
                                put_partition(state, state->next++,
                                              start_sect(p), nr_sects(p));
                }
@@@ -622,7 -620,7 +620,7 @@@ int msdos_partition(struct parsed_parti
        for (slot = 1; slot <= 4; slot++, p++) {
                if (p->boot_ind != 0 && p->boot_ind != 0x80) {
                        /*
 -                       * Even without a valid boot inidicator value
 +                       * Even without a valid boot indicator value
                         * its still possible this is valid FAT filesystem
                         * without a partition table.
                         */
        p = (struct msdos_partition *) (data + 0x1be);
        for (slot = 1 ; slot <= 4 ; slot++, p++) {
                /* If this is an EFI GPT disk, msdos should ignore it. */
-               if (SYS_IND(p) == EFI_PMBR_OSTYPE_EFI_GPT) {
+               if (p->sys_ind == EFI_PMBR_OSTYPE_EFI_GPT) {
                        put_dev_sector(sect);
                        return 0;
                }
                }
                put_partition(state, slot, start, size);
                set_info(state, slot, disksig);
-               if (SYS_IND(p) == LINUX_RAID_PARTITION)
+               if (p->sys_ind == LINUX_RAID_PARTITION)
                        state->parts[slot].flags = ADDPART_FLAG_RAID;
-               if (SYS_IND(p) == DM6_PARTITION)
+               if (p->sys_ind == DM6_PARTITION)
                        strlcat(state->pp_buf, "[DM]", PAGE_SIZE);
-               if (SYS_IND(p) == EZD_PARTITION)
+               if (p->sys_ind == EZD_PARTITION)
                        strlcat(state->pp_buf, "[EZD]", PAGE_SIZE);
        }
  
        /* second pass - output for each on a separate line */
        p = (struct msdos_partition *) (0x1be + data);
        for (slot = 1 ; slot <= 4 ; slot++, p++) {
-               unsigned char id = SYS_IND(p);
+               unsigned char id = p->sys_ind;
                int n;
  
                if (!nr_sects(p))
diff --combined net/core/netpoll.c
@@@ -36,7 -36,6 +36,7 @@@
  #include <net/ip6_checksum.h>
  #include <asm/unaligned.h>
  #include <trace/events/napi.h>
 +#include <linux/kconfig.h>
  
  /*
   * We maintain a small pool of fully-sized skbs, to make sure the
@@@ -390,8 -389,7 +390,8 @@@ void netpoll_send_udp(struct netpoll *n
        static atomic_t ip_ident;
        struct ipv6hdr *ip6h;
  
 -      WARN_ON_ONCE(!irqs_disabled());
 +      if (!IS_ENABLED(CONFIG_PREEMPT_RT))
 +              WARN_ON_ONCE(!irqs_disabled());
  
        udp_len = len + sizeof(*udph);
        if (np->ipv6)
                ip6h = ipv6_hdr(skb);
  
                /* ip6h->version = 6; ip6h->priority = 0; */
-               put_unaligned(0x60, (unsigned char *)ip6h);
+               *(unsigned char *)ip6h = 0x60;
                ip6h->flow_lbl[0] = 0;
                ip6h->flow_lbl[1] = 0;
                ip6h->flow_lbl[2] = 0;
                iph = ip_hdr(skb);
  
                /* iph->version = 4; iph->ihl = 5; */
-               put_unaligned(0x45, (unsigned char *)iph);
+               *(unsigned char *)iph = 0x45;
                iph->tos      = 0;
                put_unaligned(htons(ip_len), &(iph->tot_len));
                iph->id       = htons(atomic_inc_return(&ip_ident));