1. 07 7月, 2020 4 次提交
  2. 29 6月, 2020 1 次提交
    • R
      drm/i915: Include asm sources for {ivb, hsw}_clear_kernel.c · 55fd7e02
      Rodrigo Vivi 提交于
      Alexandre Oliva has recently removed these files from Linux Libre
      with concerns that the sources weren't available.
      
      The sources are available on IGT repository, and only open source
      tools are used to generate the {ivb,hsw}_clear_kernel.c files.
      
      However, the remaining concern from Alexandre Oliva was around
      GPL license and the source not been present when distributing
      the code.
      
      So, it looks like 2 alternatives are possible, the use of
      linux-firmware.git repository to store the blob or making sure
      that the source is also present in our tree. Since the goal
      is to limit the i915 firmware to only the micro-controller blobs
      let's make sure that we do include the asm sources here in our tree.
      
      Btw, I tried to have some diligence here and make sure that the
      asms that these commits are adding are truly the source for
      the mentioned files:
      
      igt$ ./scripts/generate_clear_kernel.sh -g ivb \
           -m ~/mesa/build/src/intel/tools/i965_asm
      Output file not specified - using default file "ivb-cb_assembled"
      
      Generating gen7 CB Kernel assembled file "ivb_clear_kernel.c"
      for i915 driver...
      
      igt$ diff ~/i915/drm-tip/drivers/gpu/drm/i915/gt/ivb_clear_kernel.c \
           ivb_clear_kernel.c
      
      <  * Generated by: IGT Gpu Tools on Fri 21 Feb 2020 05:29:32 AM UTC
      >  * Generated by: IGT Gpu Tools on Mon 08 Jun 2020 10:00:54 AM PDT
      61c61
      < };
      > };
      \ No newline at end of file
      
      igt$ ./scripts/generate_clear_kernel.sh -g hsw \
           -m ~/mesa/build/src/intel/tools/i965_asm
      Output file not specified - using default file "hsw-cb_assembled"
      
      Generating gen7.5 CB Kernel assembled file "hsw_clear_kernel.c"
      for i915 driver...
      
      igt$ diff ~/i915/drm-tip/drivers/gpu/drm/i915/gt/hsw_clear_kernel.c \
           hsw_clear_kernel.c
      5c5
      <  * Generated by: IGT Gpu Tools on Fri 21 Feb 2020 05:30:13 AM UTC
      >  * Generated by: IGT Gpu Tools on Mon 08 Jun 2020 10:01:42 AM PDT
      61c61
      < };
      > };
      \ No newline at end of file
      
      Used IGT and Mesa master repositories from Fri Jun 5 2020)
      IGT: 53e8c878a6fb ("tests/kms_chamelium: Force reprobe after replugging
           the connector")
      Mesa: 5d13c7477eb1 ("radv: set keep_statistic_info with
            RADV_DEBUG=shaderstats")
      Mesa built with: meson build -D platforms=drm,x11 -D dri-drivers=i965 \
                       -D gallium-drivers=iris -D prefix=/usr \
      		 -D libdir=/usr/lib64/ -Dtools=intel \
      		 -Dkulkan-drivers=intel && ninja -C build
      
      v2: Header clean-up and include build instructions in a readme (Chris)
          Modified commit message to respect check-patch
      
      Reference: http://www.fsfla.org/pipermail/linux-libre/2020-June/003374.html
      Reference: http://www.fsfla.org/pipermail/linux-libre/2020-June/003375.html
      Fixes: 47f8253d ("drm/i915/gen7: Clear all EU/L3 residual contexts")
      Cc: <stable@vger.kernel.org> # v5.7+
      Cc: Alexandre Oliva <lxoliva@fsfla.org>
      Cc: Prathap Kumar Valsan <prathap.kumar.valsan@intel.com>
      Cc: Akeem G Abodunrin <akeem.g.abodunrin@intel.com>
      Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Signed-off-by: NRodrigo Vivi <rodrigo.vivi@intel.com>
      Reviewed-by: NJon Bloomfield <jon.bloomfield@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20200610201807.191440-1-rodrigo.vivi@intel.com
      (cherry picked from commit 5a7eeb8b)
      Signed-off-by: NJani Nikula <jani.nikula@intel.com>
      55fd7e02
  3. 17 6月, 2020 4 次提交
    • C
      drm/i915/gvt: Use GFP_ATOMIC instead of GFP_KERNEL in atomic context · a291e4fb
      Colin Xu 提交于
      GFP_KERNEL flag specifies a normal kernel allocation in which executing
      in process context without any locks and can sleep.
      mmio_diff takes sometime to finish all the diff compare and it has
      locks, continue using GFP_KERNEL will output below trace if LOCKDEP
      enabled.
      
      Use GFP_ATOMIC instead.
      
      V2: Rebase.
      
      =====================================================
      WARNING: SOFTIRQ-safe -> SOFTIRQ-unsafe lock order detected
      5.7.0-rc2 #400 Not tainted
      -----------------------------------------------------
      is trying to acquire:
      ffffffffb47bea20 (fs_reclaim){+.+.}-{0:0}, at: fs_reclaim_acquire.part.0+0x0/0x30
      
                     and this task is already holding:
      ffff88845b85cc90 (&gvt->scheduler.mmio_context_lock){+.-.}-{2:2}, at: vgpu_mmio_diff_show+0xcf/0x2e0
      which would create a new lock dependency:
       (&gvt->scheduler.mmio_context_lock){+.-.}-{2:2} -> (fs_reclaim){+.+.}-{0:0}
      
                     but this new dependency connects a SOFTIRQ-irq-safe lock:
       (&gvt->scheduler.mmio_context_lock){+.-.}-{2:2}
      
                     ... which became SOFTIRQ-irq-safe at:
        lock_acquire+0x175/0x4e0
        _raw_spin_lock_irqsave+0x2b/0x40
        shadow_context_status_change+0xfe/0x2f0
        notifier_call_chain+0x6a/0xa0
        __atomic_notifier_call_chain+0x5f/0xf0
        execlists_schedule_out+0x42a/0x820
        process_csb+0xe7/0x3e0
        execlists_submission_tasklet+0x5c/0x1d0
        tasklet_action_common.isra.0+0xeb/0x260
        __do_softirq+0x11d/0x56f
        irq_exit+0xf6/0x100
        do_IRQ+0x7f/0x160
        ret_from_intr+0x0/0x2a
        cpuidle_enter_state+0xcd/0x5b0
        cpuidle_enter+0x37/0x60
        do_idle+0x337/0x3f0
        cpu_startup_entry+0x14/0x20
        start_kernel+0x58b/0x5c5
        secondary_startup_64+0xa4/0xb0
      
                     to a SOFTIRQ-irq-unsafe lock:
       (fs_reclaim){+.+.}-{0:0}
      
                     ... which became SOFTIRQ-irq-unsafe at:
      ...
        lock_acquire+0x175/0x4e0
        fs_reclaim_acquire.part.0+0x20/0x30
        kmem_cache_alloc_node_trace+0x2e/0x290
        alloc_worker+0x2b/0xb0
        init_rescuer.part.0+0x17/0xe0
        workqueue_init+0x293/0x3bb
        kernel_init_freeable+0x149/0x325
        kernel_init+0x8/0x116
        ret_from_fork+0x3a/0x50
      
                     other info that might help us debug this:
      
       Possible interrupt unsafe locking scenario:
      
             CPU0                    CPU1
             ----                    ----
        lock(fs_reclaim);
                                     local_irq_disable();
                                     lock(&gvt->scheduler.mmio_context_lock);
                                     lock(fs_reclaim);
        <Interrupt>
          lock(&gvt->scheduler.mmio_context_lock);
      
                      *** DEADLOCK ***
      
      3 locks held by cat/1439:
       #0: ffff888444a23698 (&p->lock){+.+.}-{3:3}, at: seq_read+0x49/0x680
       #1: ffff88845b858068 (&gvt->lock){+.+.}-{3:3}, at: vgpu_mmio_diff_show+0xc7/0x2e0
       #2: ffff88845b85cc90 (&gvt->scheduler.mmio_context_lock){+.-.}-{2:2}, at: vgpu_mmio_diff_show+0xcf/0x2e0
      
                     the dependencies between SOFTIRQ-irq-safe lock and the holding lock:
      -> (&gvt->scheduler.mmio_context_lock){+.-.}-{2:2} ops: 31 {
         HARDIRQ-ON-W at:
                          lock_acquire+0x175/0x4e0
                          _raw_spin_lock_bh+0x2f/0x40
                          vgpu_mmio_diff_show+0xcf/0x2e0
                          seq_read+0x242/0x680
                          full_proxy_read+0x95/0xc0
                          vfs_read+0xc2/0x1b0
                          ksys_read+0xc4/0x160
                          do_syscall_64+0x63/0x290
                          entry_SYSCALL_64_after_hwframe+0x49/0xb3
         IN-SOFTIRQ-W at:
                          lock_acquire+0x175/0x4e0
                          _raw_spin_lock_irqsave+0x2b/0x40
                          shadow_context_status_change+0xfe/0x2f0
                          notifier_call_chain+0x6a/0xa0
                          __atomic_notifier_call_chain+0x5f/0xf0
                          execlists_schedule_out+0x42a/0x820
                          process_csb+0xe7/0x3e0
                          execlists_submission_tasklet+0x5c/0x1d0
                          tasklet_action_common.isra.0+0xeb/0x260
                          __do_softirq+0x11d/0x56f
                          irq_exit+0xf6/0x100
                          do_IRQ+0x7f/0x160
                          ret_from_intr+0x0/0x2a
                          cpuidle_enter_state+0xcd/0x5b0
                          cpuidle_enter+0x37/0x60
                          do_idle+0x337/0x3f0
                          cpu_startup_entry+0x14/0x20
                          start_kernel+0x58b/0x5c5
                          secondary_startup_64+0xa4/0xb0
         INITIAL USE at:
                         lock_acquire+0x175/0x4e0
                         _raw_spin_lock_irqsave+0x2b/0x40
                         shadow_context_status_change+0xfe/0x2f0
                         notifier_call_chain+0x6a/0xa0
                         __atomic_notifier_call_chain+0x5f/0xf0
                         execlists_schedule_in+0x2c8/0x690
                         __execlists_submission_tasklet+0x1303/0x1930
                         execlists_submit_request+0x1e7/0x230
                         submit_notify+0x105/0x2a4
                         __i915_sw_fence_complete+0xaa/0x380
                         __engine_park+0x313/0x5a0
                         ____intel_wakeref_put_last+0x3e/0x90
                         intel_gt_resume+0x41e/0x440
                         intel_gt_init+0x283/0xbc0
                         i915_gem_init+0x197/0x240
                         i915_driver_probe+0xc2d/0x12e0
                         i915_pci_probe+0xa2/0x1e0
                         local_pci_probe+0x6f/0xb0
                         pci_device_probe+0x171/0x230
                         really_probe+0x17a/0x380
                         driver_probe_device+0x70/0xf0
                         device_driver_attach+0x82/0x90
                         __driver_attach+0x60/0x100
                         bus_for_each_dev+0xe4/0x140
                         bus_add_driver+0x257/0x2a0
                         driver_register+0xd3/0x150
                         i915_init+0x6d/0x80
                         do_one_initcall+0xb8/0x3a0
                         kernel_init_freeable+0x2b4/0x325
                         kernel_init+0x8/0x116
                         ret_from_fork+0x3a/0x50
       }
      __key.77812+0x0/0x40
       ... acquired at:
         lock_acquire+0x175/0x4e0
         fs_reclaim_acquire.part.0+0x20/0x30
         kmem_cache_alloc_trace+0x2e/0x260
         mmio_diff_handler+0xc0/0x150
         intel_gvt_for_each_tracked_mmio+0x7b/0x140
         vgpu_mmio_diff_show+0x111/0x2e0
         seq_read+0x242/0x680
         full_proxy_read+0x95/0xc0
         vfs_read+0xc2/0x1b0
         ksys_read+0xc4/0x160
         do_syscall_64+0x63/0x290
         entry_SYSCALL_64_after_hwframe+0x49/0xb3
      
                     the dependencies between the lock to be acquired
       and SOFTIRQ-irq-unsafe lock:
      -> (fs_reclaim){+.+.}-{0:0} ops: 1999031 {
         HARDIRQ-ON-W at:
                          lock_acquire+0x175/0x4e0
                          fs_reclaim_acquire.part.0+0x20/0x30
                          kmem_cache_alloc_node_trace+0x2e/0x290
                          alloc_worker+0x2b/0xb0
                          init_rescuer.part.0+0x17/0xe0
                          workqueue_init+0x293/0x3bb
                          kernel_init_freeable+0x149/0x325
                          kernel_init+0x8/0x116
                          ret_from_fork+0x3a/0x50
         SOFTIRQ-ON-W at:
                          lock_acquire+0x175/0x4e0
                          fs_reclaim_acquire.part.0+0x20/0x30
                          kmem_cache_alloc_node_trace+0x2e/0x290
                          alloc_worker+0x2b/0xb0
                          init_rescuer.part.0+0x17/0xe0
                          workqueue_init+0x293/0x3bb
                          kernel_init_freeable+0x149/0x325
                          kernel_init+0x8/0x116
                          ret_from_fork+0x3a/0x50
         INITIAL USE at:
                         lock_acquire+0x175/0x4e0
                         fs_reclaim_acquire.part.0+0x20/0x30
                         kmem_cache_alloc_node_trace+0x2e/0x290
                         alloc_worker+0x2b/0xb0
                         init_rescuer.part.0+0x17/0xe0
                         workqueue_init+0x293/0x3bb
                         kernel_init_freeable+0x149/0x325
                         kernel_init+0x8/0x116
                         ret_from_fork+0x3a/0x50
       }
      __fs_reclaim_map+0x0/0x60
       ... acquired at:
         lock_acquire+0x175/0x4e0
         fs_reclaim_acquire.part.0+0x20/0x30
         kmem_cache_alloc_trace+0x2e/0x260
         mmio_diff_handler+0xc0/0x150
         intel_gvt_for_each_tracked_mmio+0x7b/0x140
         vgpu_mmio_diff_show+0x111/0x2e0
         seq_read+0x242/0x680
         full_proxy_read+0x95/0xc0
         vfs_read+0xc2/0x1b0
         ksys_read+0xc4/0x160
         do_syscall_64+0x63/0x290
         entry_SYSCALL_64_after_hwframe+0x49/0xb3
      
                     stack backtrace:
      CPU: 5 PID: 1439 Comm: cat Not tainted 5.7.0-rc2 #400
      Hardware name: Intel(R) Client Systems NUC8i7BEH/NUC8BEB, BIOS BECFL357.86A.0056.2018.1128.1717 11/28/2018
      Call Trace:
       dump_stack+0x97/0xe0
       check_irq_usage.cold+0x428/0x434
       ? check_usage_forwards+0x2c0/0x2c0
       ? class_equal+0x11/0x20
       ? __bfs+0xd2/0x2d0
       ? in_any_class_list+0xa0/0xa0
       ? check_path+0x22/0x40
       ? check_noncircular+0x150/0x2b0
       ? print_circular_bug.isra.0+0x1b0/0x1b0
       ? mark_lock+0x13d/0xc50
       ? __lock_acquire+0x1e32/0x39b0
       __lock_acquire+0x1e32/0x39b0
       ? timerqueue_add+0xc1/0x130
       ? register_lock_class+0xa60/0xa60
       ? mark_lock+0x13d/0xc50
       lock_acquire+0x175/0x4e0
       ? __zone_pcp_update+0x80/0x80
       ? check_flags.part.0+0x210/0x210
       ? mark_held_locks+0x65/0x90
       ? _raw_spin_unlock_irqrestore+0x32/0x40
       ? lockdep_hardirqs_on+0x190/0x290
       ? fwtable_read32+0x163/0x480
       ? mmio_diff_handler+0xc0/0x150
       fs_reclaim_acquire.part.0+0x20/0x30
       ? __zone_pcp_update+0x80/0x80
       kmem_cache_alloc_trace+0x2e/0x260
       mmio_diff_handler+0xc0/0x150
       ? vgpu_mmio_diff_open+0x30/0x30
       intel_gvt_for_each_tracked_mmio+0x7b/0x140
       vgpu_mmio_diff_show+0x111/0x2e0
       ? mmio_diff_handler+0x150/0x150
       ? rcu_read_lock_sched_held+0xa0/0xb0
       ? rcu_read_lock_bh_held+0xc0/0xc0
       ? kasan_unpoison_shadow+0x33/0x40
       ? __kasan_kmalloc.constprop.0+0xc2/0xd0
       seq_read+0x242/0x680
       ? debugfs_locked_down.isra.0+0x70/0x70
       full_proxy_read+0x95/0xc0
       vfs_read+0xc2/0x1b0
       ksys_read+0xc4/0x160
       ? kernel_write+0xb0/0xb0
       ? mark_held_locks+0x24/0x90
       do_syscall_64+0x63/0x290
       entry_SYSCALL_64_after_hwframe+0x49/0xb3
      RIP: 0033:0x7ffbe3e6efb2
      Code: c0 e9 c2 fe ff ff 50 48 8d 3d ca cb 0a 00 e8 f5 19 02 00 0f 1f 44 00 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 0f 05 <48> 3d 00 f0 ff ff 77 56 c3 0f 1f 44 00 00 48 83 ec 28 48 89 54 24
      RSP: 002b:00007ffd021c08a8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
      RAX: ffffffffffffffda RBX: 0000000000020000 RCX: 00007ffbe3e6efb2
      RDX: 0000000000020000 RSI: 00007ffbe34cd000 RDI: 0000000000000003
      RBP: 00007ffbe34cd000 R08: 00007ffbe34cc010 R09: 0000000000000000
      R10: 0000000000000022 R11: 0000000000000246 R12: 0000562b6f0a11f0
      R13: 0000000000000003 R14: 0000000000020000 R15: 0000000000020000
      ------------[ cut here ]------------
      Acked-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      Signed-off-by: NColin Xu <colin.xu@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      Link: http://patchwork.freedesktop.org/patch/msgid/20200601035556.19999-1-colin.xu@intel.com
      a291e4fb
    • C
      drm/i915/gvt: Fix incorrect check of enabled bits in mask registers · fc1e3aa0
      Colin Xu 提交于
      Using _MASKED_BIT_ENABLE macro to set mask register bits is straight
      forward and not likely to go wrong. However when checking which bit(s)
      is(are) enabled, simply bitwise AND value and _MASKED_BIT_ENABLE() won't
      output expected result. Suppose the register write is disabling bit 1
      by setting 0xFFFF0000, however "& _MASKED_BIT_ENABLE(1)" outputs
      0x00010000, and the non-zero check will pass which cause the old code
      consider the new value set as an enabling operation.
      
      We found guest set 0x80008000 on boot, and set 0xffff8000 during resume.
      Both are legal settings but old code will block latter and force vgpu
      enter fail-safe mode.
      
      Introduce two new macro and make proper masked bit check in mmio handler:
      IS_MASKED_BITS_ENABLED()
      IS_MASKED_BITS_DISABLED()
      
      V2: Rebase.
      Reviewed-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      Signed-off-by: NColin Xu <colin.xu@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      Link: http://patchwork.freedesktop.org/patch/msgid/20200601030721.17129-1-colin.xu@intel.com
      fc1e3aa0
    • C
      drm/i915/gvt: Fix two CFL MMIO handling caused by regression. · fccd0f7c
      Colin Xu 提交于
      D_CFL was incorrectly removed for:
      GAMT_CHKN_BIT_REG
      GEN9_CTX_PREEMPT_REG
      
      V2: Update commit message.
      V3: Rebase and split Fixes and mis-handled MMIO.
      
      Fixes: 43226e6f (drm/i915/gvt: replaced register address with name)
      Reviewed-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      Signed-off-by: NColin Xu <colin.xu@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      Link: http://patchwork.freedesktop.org/patch/msgid/20200601030638.16002-1-colin.xu@intel.com
      fccd0f7c
    • C
      drm/i915/gvt: Add one missing MMIO handler for D_SKL_PLUS · 2de60af4
      Colin Xu 提交于
      _PLANE_CTL_3_A, _PLANE_CTL_3_B and _PLANE_SURF_3_A are handled, but
      miss _PLANE_SURF_3_B.
      Reviewed-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      Signed-off-by: NColin Xu <colin.xu@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      Link: http://patchwork.freedesktop.org/patch/msgid/20200601030457.14002-1-colin.xu@intel.com
      2de60af4
  4. 16 6月, 2020 13 次提交
  5. 15 6月, 2020 3 次提交
  6. 11 6月, 2020 1 次提交
  7. 10 6月, 2020 3 次提交
    • M
      mmap locking API: convert mmap_sem comments · c1e8d7c6
      Michel Lespinasse 提交于
      Convert comments that reference mmap_sem to reference mmap_lock instead.
      
      [akpm@linux-foundation.org: fix up linux-next leftovers]
      [akpm@linux-foundation.org: s/lockaphore/lock/, per Vlastimil]
      [akpm@linux-foundation.org: more linux-next fixups, per Michel]
      Signed-off-by: NMichel Lespinasse <walken@google.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: NVlastimil Babka <vbabka@suse.cz>
      Reviewed-by: NDaniel Jordan <daniel.m.jordan@oracle.com>
      Cc: Davidlohr Bueso <dbueso@suse.de>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: Jerome Glisse <jglisse@redhat.com>
      Cc: John Hubbard <jhubbard@nvidia.com>
      Cc: Laurent Dufour <ldufour@linux.ibm.com>
      Cc: Liam Howlett <Liam.Howlett@oracle.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ying Han <yinghan@google.com>
      Link: http://lkml.kernel.org/r/20200520052908.204642-13-walken@google.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      c1e8d7c6
    • M
      mmap locking API: use coccinelle to convert mmap_sem rwsem call sites · d8ed45c5
      Michel Lespinasse 提交于
      This change converts the existing mmap_sem rwsem calls to use the new mmap
      locking API instead.
      
      The change is generated using coccinelle with the following rule:
      
      // spatch --sp-file mmap_lock_api.cocci --in-place --include-headers --dir .
      
      @@
      expression mm;
      @@
      (
      -init_rwsem
      +mmap_init_lock
      |
      -down_write
      +mmap_write_lock
      |
      -down_write_killable
      +mmap_write_lock_killable
      |
      -down_write_trylock
      +mmap_write_trylock
      |
      -up_write
      +mmap_write_unlock
      |
      -downgrade_write
      +mmap_write_downgrade
      |
      -down_read
      +mmap_read_lock
      |
      -down_read_killable
      +mmap_read_lock_killable
      |
      -down_read_trylock
      +mmap_read_trylock
      |
      -up_read
      +mmap_read_unlock
      )
      -(&mm->mmap_sem)
      +(mm)
      Signed-off-by: NMichel Lespinasse <walken@google.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: NDaniel Jordan <daniel.m.jordan@oracle.com>
      Reviewed-by: NLaurent Dufour <ldufour@linux.ibm.com>
      Reviewed-by: NVlastimil Babka <vbabka@suse.cz>
      Cc: Davidlohr Bueso <dbueso@suse.de>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: Jerome Glisse <jglisse@redhat.com>
      Cc: John Hubbard <jhubbard@nvidia.com>
      Cc: Liam Howlett <Liam.Howlett@oracle.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ying Han <yinghan@google.com>
      Link: http://lkml.kernel.org/r/20200520052908.204642-5-walken@google.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      d8ed45c5
    • M
      mm: don't include asm/pgtable.h if linux/mm.h is already included · e31cf2f4
      Mike Rapoport 提交于
      Patch series "mm: consolidate definitions of page table accessors", v2.
      
      The low level page table accessors (pXY_index(), pXY_offset()) are
      duplicated across all architectures and sometimes more than once.  For
      instance, we have 31 definition of pgd_offset() for 25 supported
      architectures.
      
      Most of these definitions are actually identical and typically it boils
      down to, e.g.
      
      static inline unsigned long pmd_index(unsigned long address)
      {
              return (address >> PMD_SHIFT) & (PTRS_PER_PMD - 1);
      }
      
      static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
      {
              return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(address);
      }
      
      These definitions can be shared among 90% of the arches provided
      XYZ_SHIFT, PTRS_PER_XYZ and xyz_page_vaddr() are defined.
      
      For architectures that really need a custom version there is always
      possibility to override the generic version with the usual ifdefs magic.
      
      These patches introduce include/linux/pgtable.h that replaces
      include/asm-generic/pgtable.h and add the definitions of the page table
      accessors to the new header.
      
      This patch (of 12):
      
      The linux/mm.h header includes <asm/pgtable.h> to allow inlining of the
      functions involving page table manipulations, e.g.  pte_alloc() and
      pmd_alloc().  So, there is no point to explicitly include <asm/pgtable.h>
      in the files that include <linux/mm.h>.
      
      The include statements in such cases are remove with a simple loop:
      
      	for f in $(git grep -l "include <linux/mm.h>") ; do
      		sed -i -e '/include <asm\/pgtable.h>/ d' $f
      	done
      Signed-off-by: NMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Cain <bcain@codeaurora.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Greentime Hu <green.hu@gmail.com>
      Cc: Greg Ungerer <gerg@linux-m68k.org>
      Cc: Guan Xuetao <gxt@pku.edu.cn>
      Cc: Guo Ren <guoren@kernel.org>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ley Foon Tan <ley.foon.tan@intel.com>
      Cc: Mark Salter <msalter@redhat.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Mike Rapoport <rppt@kernel.org>
      Cc: Nick Hu <nickhu@andestech.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Richard Weinberger <richard@nod.at>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Vincent Chen <deanbo422@gmail.com>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: http://lkml.kernel.org/r/20200514170327.31389-1-rppt@kernel.org
      Link: http://lkml.kernel.org/r/20200514170327.31389-2-rppt@kernel.orgSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e31cf2f4
  8. 09 6月, 2020 1 次提交
  9. 08 6月, 2020 2 次提交
  10. 04 6月, 2020 1 次提交
  11. 03 6月, 2020 2 次提交
    • C
      mm: remove the prot argument from vm_map_ram · d4efd79a
      Christoph Hellwig 提交于
      This is always PAGE_KERNEL - for long term mappings with other properties
      vmap should be used.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@c-s.fr>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Gao Xiang <xiang@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Haiyang Zhang <haiyangz@microsoft.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: "K. Y. Srinivasan" <kys@microsoft.com>
      Cc: Laura Abbott <labbott@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Kelley <mikelley@microsoft.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Nitin Gupta <ngupta@vflare.org>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
      Cc: Stephen Hemminger <sthemmin@microsoft.com>
      Cc: Sumit Semwal <sumit.semwal@linaro.org>
      Cc: Wei Liu <wei.liu@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Paul Mackerras <paulus@ozlabs.org>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lkml.kernel.org/r/20200414131348.444715-19-hch@lst.deSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      d4efd79a
    • L
      gup: document and work around "COW can break either way" issue · 17839856
      Linus Torvalds 提交于
      Doing a "get_user_pages()" on a copy-on-write page for reading can be
      ambiguous: the page can be COW'ed at any time afterwards, and the
      direction of a COW event isn't defined.
      
      Yes, whoever writes to it will generally do the COW, but if the thread
      that did the get_user_pages() unmapped the page before the write (and
      that could happen due to memory pressure in addition to any outright
      action), the writer could also just take over the old page instead.
      
      End result: the get_user_pages() call might result in a page pointer
      that is no longer associated with the original VM, and is associated
      with - and controlled by - another VM having taken it over instead.
      
      So when doing a get_user_pages() on a COW mapping, the only really safe
      thing to do would be to break the COW when getting the page, even when
      only getting it for reading.
      
      At the same time, some users simply don't even care.
      
      For example, the perf code wants to look up the page not because it
      cares about the page, but because the code simply wants to look up the
      physical address of the access for informational purposes, and doesn't
      really care about races when a page might be unmapped and remapped
      elsewhere.
      
      This adds logic to force a COW event by setting FOLL_WRITE on any
      copy-on-write mapping when FOLL_GET (or FOLL_PIN) is used to get a page
      pointer as a result.
      
      The current semantics end up being:
      
       - __get_user_pages_fast(): no change. If you don't ask for a write,
         you won't break COW. You'd better know what you're doing.
      
       - get_user_pages_fast(): the fast-case "look it up in the page tables
         without anything getting mmap_sem" now refuses to follow a read-only
         page, since it might need COW breaking.  Which happens in the slow
         path - the fast path doesn't know if the memory might be COW or not.
      
       - get_user_pages() (including the slow-path fallback for gup_fast()):
         for a COW mapping, turn on FOLL_WRITE for FOLL_GET/FOLL_PIN, with
         very similar semantics to FOLL_FORCE.
      
      If it turns out that we want finer granularity (ie "only break COW when
      it might actually matter" - things like the zero page are special and
      don't need to be broken) we might need to push these semantics deeper
      into the lookup fault path.  So if people care enough, it's possible
      that we might end up adding a new internal FOLL_BREAK_COW flag to go
      with the internal FOLL_COW flag we already have for tracking "I had a
      COW".
      
      Alternatively, if it turns out that different callers might want to
      explicitly control the forced COW break behavior, we might even want to
      make such a flag visible to the users of get_user_pages() instead of
      using the above default semantics.
      
      But for now, this is mostly commentary on the issue (this commit message
      being a lot bigger than the patch, and that patch in turn is almost all
      comments), with that minimal "enable COW breaking early" logic using the
      existing FOLL_WRITE behavior.
      
      [ It might be worth noting that we've always had this ambiguity, and it
        could arguably be seen as a user-space issue.
      
        You only get private COW mappings that could break either way in
        situations where user space is doing cooperative things (ie fork()
        before an execve() etc), but it _is_ surprising and very subtle, and
        fork() is supposed to give you independent address spaces.
      
        So let's treat this as a kernel issue and make the semantics of
        get_user_pages() easier to understand. Note that obviously a true
        shared mapping will still get a page that can change under us, so this
        does _not_ mean that get_user_pages() somehow returns any "stable"
        page ]
      Reported-by: NJann Horn <jannh@google.com>
      Tested-by: NChristoph Hellwig <hch@lst.de>
      Acked-by: NOleg Nesterov <oleg@redhat.com>
      Acked-by: NKirill Shutemov <kirill@shutemov.name>
      Acked-by: NJan Kara <jack@suse.cz>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      17839856
  12. 02 6月, 2020 4 次提交
  13. 01 6月, 2020 1 次提交