Merge branch 'x86-vdso-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 23 Oct 2018 18:07:25 +0000 (19:07 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 23 Oct 2018 18:07:25 +0000 (19:07 +0100)
Pull x86 vdso updates from Ingo Molnar:
 "Two main changes:

   - Cleanups, simplifications and CLOCK_TAI support (Thomas Gleixner)

   - Improve code generation (Andy Lutomirski)"

* 'x86-vdso-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/vdso: Rearrange do_hres() to improve code generation
  x86/vdso: Document vgtod_ts better
  x86/vdso: Remove "memory" clobbers in the vDSO syscall fallbacks
  x66/vdso: Add CLOCK_TAI support
  x86/vdso: Move cycle_last handling into the caller
  x86/vdso: Simplify the invalid vclock case
  x86/vdso: Replace the clockid switch case
  x86/vdso: Collapse coarse functions
  x86/vdso: Collapse high resolution functions
  x86/vdso: Introduce and use vgtod_ts
  x86/vdso: Use unsigned int consistently for vsyscall_gtod_data:: Seq
  x86/vdso: Enforce 64bit clocksource
  x86/time: Implement clocksource_arch_init()
  clocksource: Provide clocksource_arch_init()

1  2 
arch/x86/Kconfig
arch/x86/include/asm/vgtod.h
arch/x86/kernel/time.c

diff --combined arch/x86/Kconfig
index 0a0580f2413d2386c79942bc51a16022e6369960,adc8c96df914090d7f4f69b849609ca7fcf32fec..cbd5f28ea8e2188638d0c9429cb68ae987adc4f6
@@@ -48,6 -48,7 +48,7 @@@ config X8
        select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI
        select ANON_INODES
        select ARCH_CLOCKSOURCE_DATA
+       select ARCH_CLOCKSOURCE_INIT
        select ARCH_DISCARD_MEMBLOCK
        select ARCH_HAS_ACPI_TABLE_UPGRADE      if ACPI
        select ARCH_HAS_DEBUG_VIRTUAL
        select HAVE_ARCH_AUDITSYSCALL
        select HAVE_ARCH_HUGE_VMAP              if X86_64 || X86_PAE
        select HAVE_ARCH_JUMP_LABEL
 +      select HAVE_ARCH_JUMP_LABEL_RELATIVE
        select HAVE_ARCH_KASAN                  if X86_64
        select HAVE_ARCH_KGDB
        select HAVE_ARCH_MMAP_RND_BITS          if MMU
@@@ -448,6 -448,7 +449,6 @@@ config RETPOLIN
  
  config INTEL_RDT
        bool "Intel Resource Director Technology support"
 -      default n
        depends on X86 && CPU_SUP_INTEL
        select KERNFS
        help
@@@ -523,7 -524,6 +524,7 @@@ config X86_VSM
        bool "ScaleMP vSMP"
        select HYPERVISOR_GUEST
        select PARAVIRT
 +      select PARAVIRT_XXL
        depends on X86_64 && PCI
        depends on X86_EXTENDED_PLATFORM
        depends on SMP
@@@ -702,6 -702,7 +703,6 @@@ config STA2X1
        select SWIOTLB
        select MFD_STA2X11
        select GPIOLIB
 -      default n
        ---help---
          This adds support for boards based on the STA2X11 IO-Hub,
          a.k.a. "ConneXt". The chip is used in place of the standard
@@@ -754,9 -755,6 +755,9 @@@ config PARAVIR
          over full virtualization.  However, when run without a hypervisor
          the kernel is theoretically slower and slightly larger.
  
 +config PARAVIRT_XXL
 +      bool
 +
  config PARAVIRT_DEBUG
        bool "paravirt-ops debugging"
        depends on PARAVIRT && DEBUG_KERNEL
@@@ -802,6 -800,7 +803,6 @@@ config KVM_GUES
  config KVM_DEBUG_FS
        bool "Enable debug information for KVM Guests in debugfs"
        depends on KVM_GUEST && DEBUG_FS
 -      default n
        ---help---
          This option enables collection of various statistics for KVM guest.
          Statistics are displayed in debugfs filesystem. Enabling this option
  config PARAVIRT_TIME_ACCOUNTING
        bool "Paravirtual steal time accounting"
        depends on PARAVIRT
 -      default n
        ---help---
          Select this option to enable fine granularity task steal time
          accounting. Time spent executing other tasks in parallel with
@@@ -1169,6 -1169,7 +1170,6 @@@ source "arch/x86/events/Kconfig
  
  config X86_LEGACY_VM86
        bool "Legacy VM86 support"
 -      default n
        depends on X86_32
        ---help---
          This option allows user programs to put the CPU into V8086
@@@ -1491,14 -1492,6 +1492,14 @@@ config X86_DIRECT_GBPAGE
          supports them), so don't confuse the user by printing
          that we have them enabled.
  
 +config X86_CPA_STATISTICS
 +      bool "Enable statistic for Change Page Attribute"
 +      depends on DEBUG_FS
 +      ---help---
 +        Expose statistics about the Change Page Attribute mechanims, which
 +        helps to determine the effectivness of preserving large and huge
 +        page mappings when mapping protections are changed.
 +
  config ARCH_HAS_MEM_ENCRYPT
        def_bool y
  
@@@ -2228,6 -2221,7 +2229,6 @@@ config HOTPLUG_CP
  
  config BOOTPARAM_HOTPLUG_CPU0
        bool "Set default setting of cpu0_hotpluggable"
 -      default n
        depends on HOTPLUG_CPU
        ---help---
          Set whether default state of cpu0_hotpluggable is on or off.
@@@ -2429,7 -2423,7 +2430,7 @@@ menu "Power management and ACPI options
  
  config ARCH_HIBERNATION_HEADER
        def_bool y
 -      depends on X86_64 && HIBERNATION
 +      depends on HIBERNATION
  
  source "kernel/power/Kconfig"
  
@@@ -2749,7 -2743,8 +2750,7 @@@ config OLP
  
  config OLPC_XO1_PM
        bool "OLPC XO-1 Power Management"
 -      depends on OLPC && MFD_CS5535 && PM_SLEEP
 -      select MFD_CORE
 +      depends on OLPC && MFD_CS5535=y && PM_SLEEP
        ---help---
          Add support for poweroff and suspend of the OLPC XO-1 laptop.
  
@@@ -2831,6 -2826,7 +2832,6 @@@ source "drivers/pcmcia/Kconfig
  config RAPIDIO
        tristate "RapidIO support"
        depends on PCI
 -      default n
        help
          If enabled this option will include drivers and the core
          infrastructure code to support RapidIO interconnect devices.
index 056a61c8c5c746fc5c32a429e81e7a1a6d09a863,69d05c6d47f58525a30454687ebb56c20886c96b..913a133f8e6f98e635b6c348e58522a538d7da22
@@@ -5,33 -5,46 +5,46 @@@
  #include <linux/compiler.h>
  #include <linux/clocksource.h>
  
+ #include <uapi/linux/time.h>
  #ifdef BUILD_VDSO32_64
  typedef u64 gtod_long_t;
  #else
  typedef unsigned long gtod_long_t;
  #endif
+ /*
+  * There is one of these objects in the vvar page for each
+  * vDSO-accelerated clockid.  For high-resolution clocks, this encodes
+  * the time corresponding to vsyscall_gtod_data.cycle_last.  For coarse
+  * clocks, this encodes the actual time.
+  *
+  * To confuse the reader, for high-resolution clocks, nsec is left-shifted
+  * by vsyscall_gtod_data.shift.
+  */
+ struct vgtod_ts {
+       u64             sec;
+       u64             nsec;
+ };
+ #define VGTOD_BASES   (CLOCK_TAI + 1)
+ #define VGTOD_HRES    (BIT(CLOCK_REALTIME) | BIT(CLOCK_MONOTONIC) | BIT(CLOCK_TAI))
+ #define VGTOD_COARSE  (BIT(CLOCK_REALTIME_COARSE) | BIT(CLOCK_MONOTONIC_COARSE))
  /*
   * vsyscall_gtod_data will be accessed by 32 and 64 bit code at the same time
   * so be carefull by modifying this structure.
   */
  struct vsyscall_gtod_data {
-       unsigned seq;
-       int vclock_mode;
-       u64     cycle_last;
-       u64     mask;
-       u32     mult;
-       u32     shift;
-       /* open coded 'struct timespec' */
-       u64             wall_time_snsec;
-       gtod_long_t     wall_time_sec;
-       gtod_long_t     monotonic_time_sec;
-       u64             monotonic_time_snsec;
-       gtod_long_t     wall_time_coarse_sec;
-       gtod_long_t     wall_time_coarse_nsec;
-       gtod_long_t     monotonic_time_coarse_sec;
-       gtod_long_t     monotonic_time_coarse_nsec;
+       unsigned int    seq;
+       int             vclock_mode;
+       u64             cycle_last;
+       u64             mask;
+       u32             mult;
+       u32             shift;
+       struct vgtod_ts basetime[VGTOD_BASES];
  
        int             tz_minuteswest;
        int             tz_dsttime;
@@@ -44,9 -57,9 +57,9 @@@ static inline bool vclock_was_used(int 
        return READ_ONCE(vclocks_used) & (1 << vclock);
  }
  
- static inline unsigned gtod_read_begin(const struct vsyscall_gtod_data *s)
+ static inline unsigned int gtod_read_begin(const struct vsyscall_gtod_data *s)
  {
-       unsigned ret;
+       unsigned int ret;
  
  repeat:
        ret = READ_ONCE(s->seq);
@@@ -59,7 -72,7 +72,7 @@@
  }
  
  static inline int gtod_read_retry(const struct vsyscall_gtod_data *s,
-                                       unsigned start)
+                                 unsigned int start)
  {
        smp_rmb();
        return unlikely(s->seq != start);
@@@ -77,4 -90,30 +90,4 @@@ static inline void gtod_write_end(struc
        ++s->seq;
  }
  
 -#ifdef CONFIG_X86_64
 -
 -#define VGETCPU_CPU_MASK 0xfff
 -
 -static inline unsigned int __getcpu(void)
 -{
 -      unsigned int p;
 -
 -      /*
 -       * Load per CPU data from GDT.  LSL is faster than RDTSCP and
 -       * works on all CPUs.  This is volatile so that it orders
 -       * correctly wrt barrier() and to keep gcc from cleverly
 -       * hoisting it out of the calling function.
 -       *
 -       * If RDPID is available, use it.
 -       */
 -      alternative_io ("lsl %[seg],%[p]",
 -                      ".byte 0xf3,0x0f,0xc7,0xf8", /* RDPID %eax/rax */
 -                      X86_FEATURE_RDPID,
 -                      [p] "=a" (p), [seg] "r" (__PER_CPU_SEG));
 -
 -      return p;
 -}
 -
 -#endif /* CONFIG_X86_64 */
 -
  #endif /* _ASM_X86_VGTOD_H */
diff --combined arch/x86/kernel/time.c
index fddaefc51fb6d7ead6630ec8bfedae9bcb94d582,b23f5420b26a244d0406e06494719851b4ce3ad7..0e14f6c0d35e0f7ef0998963390eab9587d8186e
@@@ -10,6 -10,7 +10,7 @@@
   *
   */
  
+ #include <linux/clocksource.h>
  #include <linux/clockchips.h>
  #include <linux/interrupt.h>
  #include <linux/irq.h>
@@@ -25,7 -26,7 +26,7 @@@
  #include <asm/time.h>
  
  #ifdef CONFIG_X86_64
 -__visible volatile unsigned long jiffies __cacheline_aligned = INITIAL_JIFFIES;
 +__visible volatile unsigned long jiffies __cacheline_aligned_in_smp = INITIAL_JIFFIES;
  #endif
  
  unsigned long profile_pc(struct pt_regs *regs)
@@@ -105,3 -106,24 +106,24 @@@ void __init time_init(void
  {
        late_time_init = x86_late_time_init;
  }
+ /*
+  * Sanity check the vdso related archdata content.
+  */
+ void clocksource_arch_init(struct clocksource *cs)
+ {
+       if (cs->archdata.vclock_mode == VCLOCK_NONE)
+               return;
+       if (cs->archdata.vclock_mode > VCLOCK_MAX) {
+               pr_warn("clocksource %s registered with invalid vclock_mode %d. Disabling vclock.\n",
+                       cs->name, cs->archdata.vclock_mode);
+               cs->archdata.vclock_mode = VCLOCK_NONE;
+       }
+       if (cs->mask != CLOCKSOURCE_MASK(64)) {
+               pr_warn("clocksource %s registered with invalid mask %016llx. Disabling vclock.\n",
+                       cs->name, cs->mask);
+               cs->archdata.vclock_mode = VCLOCK_NONE;
+       }
+ }