KVM: s390: Don't use %pK through tracepoints
Subsystems (16)
Sasha Levin
maintainerPATCH 1/34 KVM: s390: Don't use %pK through tracepoints
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 6c9567e0850be2f0f94ab64fa6512413fd1a1eb1 ]
Restricted pointers ("%pK") are not meant to be used through TP_format(). It can unintentionally expose security sensitive, raw pointer values.
Use regular pointer formatting instead.
Message-ID: <20250217-restricted-pointers-s390-v1-1-0e4ace75d8aa@linutronix.de>
--- arch/s390/kvm/trace-s390.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/kvm/trace-s390.h +2 -2
@@ -56,7 +56,7 @@ TRACE_EVENT(kvm_s390_create_vcpu, __entry->sie_block = sie_block; ), -TP_printk ("create cpu %d at 0x%pK, sie block at 0x%pK" , +TP_printk ("create cpu %d at 0x%p, sie block at 0x%p" , __entry->id, __entry->vcpu, __entry->sie_block) );
@@ -255,7 +255,7 @@ TRACE_EVENT(kvm_s390_enable_css, __entry->kvm = kvm; ), -TP_printk ("enabling channel I/O support (kvm @ %pK)\n" , +TP_printk ("enabling channel I/O support (kvm @ %p)\n" , __entry->kvm) );
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 2/34 KVM: s390: Don't use %pK through debug printing
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 0c7fbae5bc782429c97d68dc40fb126748d7e352 ]
Restricted pointers ("%pK") are only meant to be used when directly printing to a file from task context.
Otherwise it can unintentionally expose security sensitive, raw pointer values.
Use regular pointer formatting instead.
Message-ID: <20250217-restricted-pointers-s390-v1-2-0e4ace75d8aa@linutronix.de>
--- arch/s390/kvm/intercept.c | 2 +- arch/s390/kvm/interrupt.c | 8 ++++---- arch/s390/kvm/kvm-s390.c | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-)
arch/s390/kvm/intercept.c +1 -1
@@ -95,7 +95,7 @@ static int handle_validity(struct kvm_vcpu *vcpu) vcpu->stat.exit_validity++;trace_kvm_s390_intercept_validity (vcpu, viwhy); -KVM_EVENT (3 ,"validity intercept 0x%x for pid %u (kvm 0x%pK)" , viwhy, +KVM_EVENT (3 ,"validity intercept 0x%x for pid %u (kvm 0x%p)" , viwhy, current->pid, vcpu->kvm);/* do not warn on invalid runtime instrumentation mode */
arch/s390/kvm/interrupt.c +4 -4
@@ -3161,7 +3161,7 @@ void kvm_s390_gisa_clear(struct kvm *kvm)if (!gi->origin)return ;gisa_clear_ipm (gi->origin); -VM_EVENT (kvm,3 ,"gisa 0x%pK cleared" , gi->origin); +VM_EVENT (kvm,3 ,"gisa 0x%p cleared" , gi->origin); }void kvm_s390_gisa_init (struct kvm *kvm)
@@ -3178,7 +3178,7 @@ void kvm_s390_gisa_init(struct kvm *kvm) gi->timer.function = gisa_vcpu_kicker;memset (gi->origin,0 ,sizeof (struct kvm_s390_gisa )); gi->origin->next_alert = (u32 )virt_to_phys (gi->origin); -VM_EVENT (kvm,3 ,"gisa 0x%pK initialized" , gi->origin); +VM_EVENT (kvm,3 ,"gisa 0x%p initialized" , gi->origin); }void kvm_s390_gisa_enable (struct kvm *kvm)
@@ -3219,7 +3219,7 @@ void kvm_s390_gisa_destroy(struct kvm *kvm)process_gib_alert_list ();hrtimer_cancel (&gi->timer); gi->origin =NULL ; -VM_EVENT (kvm,3 ,"gisa 0x%pK destroyed" , gisa); +VM_EVENT (kvm,3 ,"gisa 0x%p destroyed" , gisa); }void kvm_s390_gisa_disable (struct kvm *kvm)
@@ -3468,7 +3468,7 @@ int __init kvm_s390_gib_init(u8 nisc) } } -KVM_EVENT (3 ,"gib 0x%pK (nisc=%d) initialized" , gib, gib->nisc); +KVM_EVENT (3 ,"gib 0x%p (nisc=%d) initialized" , gib, gib->nisc); goto out; out_unreg_gal:
arch/s390/kvm/kvm-s390.c +5 -5
@@ -1020,7 +1020,7 @@ static int kvm_s390_set_mem_control(struct kvm *kvm, struct kvm_device_attr *att }mutex_unlock (&kvm->lock);VM_EVENT (kvm,3 ,"SET: max guest address: %lu" , new_limit); -VM_EVENT (kvm,3 ,"New guest asce: 0x%pK" , +VM_EVENT (kvm,3 ,"New guest asce: 0x%p" , (void *) kvm->arch.gmap->asce);break ; }
@@ -3464,7 +3464,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)kvm_s390_gisa_init (kvm);INIT_LIST_HEAD (&kvm->arch.pv.need_cleanup); kvm->arch.pv.set_aside =NULL ; -KVM_EVENT (3 ,"vm 0x%pK created by pid %u" , kvm, current->pid); +KVM_EVENT (3 ,"vm 0x%p created by pid %u" , kvm, current->pid);return 0 ; out_err:
@@ -3527,7 +3527,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)kvm_s390_destroy_adapters (kvm);kvm_s390_clear_float_irqs (kvm);kvm_s390_vsie_destroy (kvm); -KVM_EVENT (3 ,"vm 0x%pK destroyed" , kvm); +KVM_EVENT (3 ,"vm 0x%p destroyed" , kvm); }/* Section: vcpu related */
@@ -3648,7 +3648,7 @@ static int sca_switch_to_extended(struct kvm *kvm)free_page ((unsigned long )old_sca); -VM_EVENT (kvm,2 ,"Switched to ESCA (0x%pK -> 0x%pK)" , +VM_EVENT (kvm,2 ,"Switched to ESCA (0x%p -> 0x%p)" , old_sca, kvm->arch.sca);return 0 ; }
@@ -4025,7 +4025,7 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) goto out_free_sie_block; } -VM_EVENT (vcpu->kvm,3 ,"create cpu %d at 0x%pK, sie block at 0x%pK" , +VM_EVENT (vcpu->kvm,3 ,"create cpu %d at 0x%p, sie block at 0x%p" , vcpu->vcpu_id, vcpu, vcpu->arch.sie_block);trace_kvm_s390_create_vcpu (vcpu->vcpu_id, vcpu, vcpu->arch.sie_block);
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 3/34 udmabuf: fix a buf size overflow issue during udmabuf creation
In reply to Sasha LevinFrom: Xiaogang Chen <[email protected]>
[ Upstream commit 021ba7f1babd029e714d13a6bf2571b08af96d0f ]
by casting size_limit_mb to u64 when calculate pglimit.
--- drivers/dma-buf/udmabuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma-buf/udmabuf.c +1 -1
@@ -393,7 +393,7 @@ static long udmabuf_create(struct miscdevice *device,if (!ubuf)return -ENOMEM ; - pglimit = (size_limit_mb *1024 *1024 ) >>PAGE_SHIFT ; + pglimit = ((u64 )size_limit_mb *1024 *1024 ) >>PAGE_SHIFT ;for (i =0 ; i < head->count; i++) {pgoff_t subpgcnt;
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 4/34 cgroup/cpuset: Don't allow creation of local partition over a remote one
In reply to Sasha LevinFrom: Waiman Long <[email protected]>
[ Upstream commit 6da580ec656a5ed135db2cdf574b47635611a4d7 ]
Currently, we don't allow the creation of a remote partition underneath another local or remote partition. However, it is currently possible to create a new local partition with an existing remote partition underneath it if top_cpuset is the parent. However, the current cpuset code does not set the effective exclusive CPUs correctly to account for those that are taken by the remote partition.
Changing the code to properly account for those remote partition CPUs under all possible circumstances can be complex. It is much easier to not allow such a configuration which is not that useful. So forbid that by making sure that exclusive_cpus mask doesn't overlap with subpartitions_cpus and invalidate the partition if that happens.
--- kernel/cgroup/cpuset-internal.h | 1 + kernel/cgroup/cpuset.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+)
kernel/cgroup/cpuset-internal.h +1 -0
@@ -33,6 +33,7 @@ enum prs_errcode {PERR_CPUSEMPTY ,PERR_HKEEPING ,PERR_ACCESS , + PERR_REMOTE, };/* bits in struct cpuset flags field */
kernel/cgroup/cpuset.c +14 -0
@@ -62,6 +62,7 @@ static const char * const perr_strings[] = { [PERR_CPUSEMPTY] = "cpuset.cpus and cpuset.cpus.exclusive are empty", [PERR_HKEEPING] = "partition config conflicts with housekeeping setup", [PERR_ACCESS] = "Enable partition not permitted", + [PERR_REMOTE] = "Have remote partition underneath", };/*
@@ -2830,6 +2831,19 @@ static int update_prstate(struct cpuset *cs, int new_prs) goto out; } +/* +* We don't support the creation of a new local partition with +* a remote partition underneath it. This unsupported +* setting can happen only if parent is the top_cpuset because +* a remote partition cannot be created underneath an existing +* local or remote partition. +*/ +if ((parent == &top_cpuset) && +cpumask_intersects (cs->exclusive_cpus, subpartitions_cpus)) { + err =PERR_REMOTE ; + goto out; + } +/* * If parent is valid partition, enable local partiion. * Otherwise, enable a remote partition.
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 5/34 selftests: ublk: fix test_stripe_04
In reply to Sasha LevinFrom: Ming Lei <[email protected]>
[ Upstream commit 72070e57b0a518ec8e562a2b68fdfc796ef5c040 ]
Commit 57ed58c13256 ("selftests: ublk: enable zero copy for stripe target") added test entry of test_stripe_04, but forgot to add the test script.
So fix the test by adding the script file.
--- .../testing/selftests/ublk/test_stripe_04.sh | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 tools/testing/selftests/ublk/test_stripe_04.sh
tools/testing/selftests/ublk/test_stripe_04.sh new file +24 -0
@@ -0,0 +1,24 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="stripe_04" +ERR_CODE=0 + +_prep_test "stripe" "mkfs & mount & umount on zero copy" + +backfile_0=$(_create_backfile 256M) +backfile_1=$(_create_backfile 256M) +dev_id=$(_add_ublk_dev -t stripe -z -q 2 "$backfile_0" "$backfile_1") +_check_add_dev $TID $? "$backfile_0" "$backfile_1" + +_mkfs_mount_test /dev/ublkb"${dev_id}" +ERR_CODE=$? + +_cleanup_test "stripe" + +_remove_backfile "$backfile_0" +_remove_backfile "$backfile_1" + +_show_result $TID $ERR_CODE
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 6/34 perf/core: Fix WARN_ON(!ctx) in __free_event() for partial init
In reply to Sasha LevinFrom: Gabriel Shahrouzi <[email protected]>
[ Upstream commit 0ba3a4ab76fd3367b9cb680cad70182c896c795c ]
Move the get_ctx(child_ctx) call and the child_event->ctx assignment to occur immediately after the child event is allocated. Ensure that child_event->ctx is non-NULL before any subsequent error path within inherit_event calls free_event(), satisfying the assumptions of the cleanup code.
Details:
There's no clear Fixes tag, because this bug is a side-effect of multiple interacting commits over time (up to 15 years old), not a single regression.
The code initially incremented refcount then assigned context immediately after the child_event was created. Later, an early validity check for child_event was added before the refcount/assignment. Even later, a WARN_ON_ONCE() cleanup check was added, assuming event->ctx is valid if the pmu_ctx is valid. The problem is that the WARN_ON_ONCE() could trigger after the initial check passed but before child_event->ctx was assigned, violating its precondition. The solution is to assign child_event->ctx right after its initial validation. This ensures the context exists for any subsequent checks or cleanup routines, resolving the WARN_ON_ONCE().
To resolve it, defer the refcount update and child_event->ctx assignment directly after child_event->pmu_ctx is set but before checking if the parent event is orphaned. The cleanup routine depends on event->pmu_ctx being non-NULL before it verifies event->ctx is non-NULL. This also maintains the author's original intent of passing in child_ctx to find_get_pmu_context before its refcount/assignment.
[ mingo: Expanded the changelog from another email by Gabriel Shahrouzi. ]
--- kernel/events/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/events/core.c +3 -3
@@ -13729,6 +13729,9 @@ inherit_event(struct perf_event *parent_event,if (IS_ERR (child_event))return child_event; +get_ctx (child_ctx); + child_event->ctx = child_ctx; + pmu_ctx =find_get_pmu_context (child_event->pmu, child_ctx, child_event);if (IS_ERR (pmu_ctx)) {free_event (child_event);
@@ -13751,8 +13754,6 @@ inherit_event(struct perf_event *parent_event,return NULL ; } -get_ctx (child_ctx); -/* * Make the child state follow the state of the parent event, * not its attr.disabled bit. We hold the parent's mutex,
@@ -13773,7 +13774,6 @@ inherit_event(struct perf_event *parent_event,local64_set (&hwc->period_left, sample_period); } - child_event->ctx = child_ctx; child_event->overflow_handler = parent_event->overflow_handler; child_event->overflow_handler_context = parent_event->overflow_handler_context;
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 7/34 xen: Change xen-acpi-processor dom0 dependency
In reply to Sasha LevinFrom: Jason Andryuk <[email protected]>
[ Upstream commit 0f2946bb172632e122d4033e0b03f85230a29510 ]
xen-acpi-processor functions under a PVH dom0 with only a xen_initial_domain() runtime check. Change the Kconfig dependency from PV dom0 to generic dom0 to reflect that.
Message-ID: <[email protected]>
--- drivers/xen/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/xen/Kconfig +1 -1
@@ -278,7 +278,7 @@ config XEN_PRIVCMD_EVENTFD config XEN_ACPI_PROCESSOR tristate "Xen ACPI processor" - depends on XEN && XEN_PV_DOM0 && X86 && ACPI_PROCESSOR && CPU_FREQ + depends on XEN && XEN_DOM0 && X86 && ACPI_PROCESSOR && CPU_FREQ default m help This ACPI processor uploads Power Management information to the Xen
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 8/34 pwm: Let pwm_set_waveform() succeed even if lowlevel driver rounded up
In reply to Sasha LevinFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 00e53d0f4baedd72196b65f00698b2a5a537dc2b ]
Waveform parameters are supposed to be rounded down to the next value possible for the hardware. However when a requested value is too small, .round_waveform_tohw() is supposed to pick the next bigger value and return 1. Let pwm_set_waveform() behave in the same way.
This creates consistency between pwm_set_waveform_might_sleep() with exact=false and pwm_round_waveform_might_sleep() + pwm_set_waveform_might_sleep() with exact=true.
The PWM_DEBUG rounding check has to be adapted to only trigger if no uprounding happend.
--- drivers/pwm/core.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/pwm/core.c +7 -6
@@ -322,7 +322,7 @@ static int __pwm_set_waveform(struct pwm_device *pwm,const struct pwm_ops *ops = chip->ops;char wfhw[WFHWSIZE ];struct pwm_waveform wf_rounded; -int err; +int err, ret_tohw;BUG_ON (WFHWSIZE < ops->sizeof_wfhw);
@@ -332,16 +332,16 @@ static int __pwm_set_waveform(struct pwm_device *pwm,if (!pwm_wf_valid (wf))return -EINVAL ; - err =__pwm_round_waveform_tohw (chip, pwm, wf, &wfhw); -if (err) -return err; + ret_tohw =__pwm_round_waveform_tohw (chip, pwm, wf, &wfhw); +if (ret_tohw <0 ) +return ret_tohw;if ((IS_ENABLED (CONFIG_PWM_DEBUG ) || exact) && wf->period_length_ns) { err =__pwm_round_waveform_fromhw (chip, pwm, &wfhw, &wf_rounded);if (err)return err; -if (IS_ENABLED (CONFIG_PWM_DEBUG ) && !pwm_check_rounding (wf, &wf_rounded)) +if (IS_ENABLED (CONFIG_PWM_DEBUG ) && ret_tohw ==0 && !pwm_check_rounding (wf, &wf_rounded))dev_err (&chip->dev,"Wrong rounding: requested %llu/%llu [+%llu], result %llu/%llu [+%llu]\n" , wf->duty_length_ns, wf->period_length_ns, wf->duty_offset_ns, wf_rounded.duty_length_ns, wf_rounded.period_length_ns, wf_rounded.duty_offset_ns);
@@ -382,7 +382,8 @@ static int __pwm_set_waveform(struct pwm_device *pwm, wf_rounded.duty_length_ns, wf_rounded.period_length_ns, wf_rounded.duty_offset_ns, wf_set.duty_length_ns, wf_set.period_length_ns, wf_set.duty_offset_ns); } -return 0 ; + +return ret_tohw; }/**
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 9/34 pwm: axi-pwmgen: Let .round_waveform_tohw() signal when request was rounded up
In reply to Sasha LevinFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit a85e08a05bf77d5d03b4ac0c59768a606a1b640b ]
The .round_waveform_tohw() is supposed to return 1 if the requested waveform cannot be implemented by rounding down all parameters. Also adapt the corresponding comment to better describe why the implemented procedure is right.
--- drivers/pwm/pwm-axi-pwmgen.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/pwm/pwm-axi-pwmgen.c +7 -3
@@ -75,6 +75,7 @@ static int axi_pwmgen_round_waveform_tohw(struct pwm_chip *chip, {struct axi_pwmgen_waveform *wfhw = _wfhw;struct axi_pwmgen_ddata *ddata =axi_pwmgen_ddata_from_chip (chip); +int ret =0 ;if (wf->period_length_ns ==0 ) { *wfhw = (struct axi_pwmgen_waveform){
@@ -91,12 +92,15 @@ static int axi_pwmgen_round_waveform_tohw(struct pwm_chip *chip,if (wfhw->period_cnt ==0 ) {/* * The specified period is too short for the hardware. -* Let's round .duty_cycle down to 0 to get a (somewhat) -* valid result. +* So round up .period_cnt to 1 (i.e. the smallest +* possible period). With .duty_cycle and .duty_offset +* being less than or equal to .period, their rounded +* value must be 0. */ wfhw->period_cnt =1 ; wfhw->duty_cycle_cnt =0 ; wfhw->duty_offset_cnt =0 ; + ret =1 ; }else { wfhw->duty_cycle_cnt = min_t(u64, mul_u64_u32_div(wf->duty_length_ns, ddata->clk_rate_hz, NSEC_PER_SEC),
@@ -111,7 +115,7 @@ static int axi_pwmgen_round_waveform_tohw(struct pwm_chip *chip, pwm->hwpwm, wf->duty_length_ns, wf->period_length_ns, wf->duty_offset_ns, ddata->clk_rate_hz, wfhw->period_cnt, wfhw->duty_cycle_cnt, wfhw->duty_offset_cnt); -return 0 ; +return ret; } static int axi_pwmgen_round_waveform_fromhw(struct pwm_chip *chip, struct pwm_device *pwm,
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 10/34 nvme: requeue namespace scan on missed AENs
In reply to Sasha LevinFrom: Hannes Reinecke <[email protected]>
[ Upstream commit 9546ad1a9bda7362492114f5866b95b0ac4a100e ]
Scanning for namespaces can take some time, so if the target is reconfigured while the scan is running we may miss a Attached Namespace Attribute Changed AEN.
Check if the NVME_AER_NOTICE_NS_CHANGED bit is set once the scan has finished, and requeue scanning to pick up any missed change.
--- drivers/nvme/host/core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/nvme/host/core.c +4 -0
@@ -4292,6 +4292,10 @@ static void nvme_scan_work(struct work_struct *work)nvme_scan_ns_sequential (ctrl); }mutex_unlock (&ctrl->scan_lock); + +/* Requeue if we have missed AENs */ +if (test_bit (NVME_AER_NOTICE_NS_CHANGED , &ctrl->events)) +nvme_queue_scan (ctrl); }/*
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 11/34 ACPI: EC: Set ec_no_wakeup for Lenovo Go S
In reply to Sasha LevinFrom: Mario Limonciello <[email protected]>
[ Upstream commit b988685388effd648150aab272533f833a2a70f0 ]
When AC adapter is unplugged or plugged in EC wakes from HW sleep but APU doesn't enter back into HW sleep.
The reason this happens is that, when the APU exits HW sleep, the power rails controlled by the EC will power up the TCON. The TCON has a GPIO that will be toggled at this time. The GPIO is not marked as a wakeup source, but the GPIO controller still has an unserviced interrupt. Unserviced interrupts will block entering HW sleep again. Clearing the GPIO doesn't help as the TCON continues to assert it until it's been initialized by i2c-hid.
Fixing this would require TCON F/W changes and it's already broken in the wild on production hardware.
To avoid triggering this issue add a quirk to avoid letting EC wake up system at all. The power button still works properly on this system.
--- drivers/acpi/ec.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/acpi/ec.c +28 -0
@@ -2301,6 +2301,34 @@ static const struct dmi_system_id acpi_ec_no_wakeup[] = { DMI_MATCH(DMI_PRODUCT_FAMILY, "103C_5336AN HP ZHAN 66 Pro"), }, }, +/* +* Lenovo Legion Go S; touchscreen blocks HW sleep when woken up from EC +* https://gitlab.freedesktop.org/drm/amd/-/issues/3929 +*/ + { + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_NAME, "83L3"), + } + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_NAME, "83N6"), + } + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_NAME, "83Q2"), + } + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_NAME, "83Q3"), + } + }, { }, };
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 12/34 ACPI PPTT: Fix coding mistakes in a couple of sizeof() calls
In reply to Sasha LevinFrom: Jean-Marc Eurin <[email protected]>
[ Upstream commit 7ab4f0e37a0f4207e742a8de69be03984db6ebf0 ]
The end of table checks should be done with the structure size, but 2 of the 3 similar calls use the pointer size.
--- drivers/acpi/pptt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/pptt.c +2 -2
@@ -229,7 +229,7 @@ static int acpi_pptt_leaf_node(struct acpi_table_header *table_hdr, node_entry =ACPI_PTR_DIFF (node, table_hdr); entry = ACPI_ADD_PTR(struct acpi_subtable_header, table_hdr,sizeof (struct acpi_table_pptt )); - proc_sz =sizeof (struct acpi_pptt_processor *); + proc_sz =sizeof (struct acpi_pptt_processor );while ((unsigned long )entry + proc_sz < table_end) { cpu_node = (struct acpi_pptt_processor *)entry;
@@ -270,7 +270,7 @@ static struct acpi_pptt_processor *acpi_find_processor_node(struct acpi_table_he table_end = (unsigned long )table_hdr + table_hdr->length; entry = ACPI_ADD_PTR(struct acpi_subtable_header, table_hdr,sizeof (struct acpi_table_pptt )); - proc_sz =sizeof (struct acpi_pptt_processor *); + proc_sz =sizeof (struct acpi_pptt_processor );/* find the processor structure associated with this cpuid */ while ((unsigned long )entry + proc_sz < table_end) {
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 13/34 drm/amdkfd: sriov doesn't support per queue reset
In reply to Sasha LevinFrom: Emily Deng <[email protected]>
[ Upstream commit ba6d8f878d6180d4d0ed0574479fc1e232928184 ]
Disable per queue reset for sriov.
--- drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +2 -1
@@ -2000,7 +2000,8 @@ static void kfd_topology_set_capabilities(struct kfd_topology_device *dev) dev->node_props.capability |=HSA_CAP_TRAP_DEBUG_PRECISE_MEMORY_OPERATIONS_SUPPORTED ; - dev->node_props.capability |=HSA_CAP_PER_QUEUE_RESET_SUPPORTED ; +if (!amdgpu_sriov_vf (dev->gpu->adev)) + dev->node_props.capability |=HSA_CAP_PER_QUEUE_RESET_SUPPORTED ; }else { dev->node_props.debug_prop |=HSA_DBG_WATCH_ADDR_MASK_LO_BIT_GFX10 |HSA_DBG_WATCH_ADDR_MASK_HI_BIT ;
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 14/34 drm/amdgpu: Increase KIQ invalidate_tlbs timeout
In reply to Sasha LevinFrom: Jay Cornwall <[email protected]>
[ Upstream commit 3666ed821832f42baaf25f362680dda603cde732 ]
KIQ invalidate_tlbs request has been seen to marginally exceed the configured 100 ms timeout on systems under load.
All other KIQ requests in the driver use a 10 second timeout. Use a similar timeout implementation on the invalidate_tlbs path.
v2: Poll once before msleep
v3: Fix return value
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -1
@@ -352,7 +352,6 @@ enum amdgpu_kiq_irq {AMDGPU_CP_KIQ_IRQ_DRIVER0 =0 , AMDGPU_CP_KIQ_IRQ_LAST }; -#define SRIOV_USEC_TIMEOUT 1200000/* wait 12 * 100ms for SRIOV */ #define MAX_KIQ_REG_WAIT 5000/* in usecs, 5ms */ #define MAX_KIQ_REG_BAILOUT_INTERVAL 5/* in msecs, 5ms */ #define MAX_KIQ_REG_TRY 1000
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +14 -5
@@ -678,12 +678,10 @@ int amdgpu_gmc_flush_gpu_tlb_pasid(struct amdgpu_device *adev, uint16_t pasid, uint32_t flush_type, bool all_hub, uint32_t inst) { - u32 usec_timeout = amdgpu_sriov_vf(adev) ? SRIOV_USEC_TIMEOUT : - adev->usec_timeout; struct amdgpu_ring *ring = &adev->gfx.kiq[inst].ring;struct amdgpu_kiq *kiq = &adev->gfx.kiq[inst];unsigned int ndw; -int r; +int r, cnt =0 ;uint32_t seq;/*
@@ -740,10 +738,21 @@ int amdgpu_gmc_flush_gpu_tlb_pasid(struct amdgpu_device *adev, uint16_t pasid,amdgpu_ring_commit (ring);spin_unlock (&adev->gfx.kiq[inst].ring_lock); -if (amdgpu_fence_wait_polling (ring, seq, usec_timeout) <1 ) { + + r =amdgpu_fence_wait_polling (ring, seq,MAX_KIQ_REG_WAIT ); + +might_sleep (); +while (r <1 && cnt++ <MAX_KIQ_REG_TRY && + !amdgpu_reset_pending (adev->reset_domain)) { +msleep (MAX_KIQ_REG_BAILOUT_INTERVAL ); + r =amdgpu_fence_wait_polling (ring, seq,MAX_KIQ_REG_WAIT ); + } + +if (cnt >MAX_KIQ_REG_TRY ) {dev_err (adev->dev,"timeout waiting for kiq fence\n" ); r = -ETIME ; - } + }else + r =0 ; } error_unlock_reset:
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 15/34 drm/amdgpu: allow pinning DMA-bufs into VRAM if all importers can do P2P
In reply to Sasha LevinFrom: Christian König <[email protected]>
[ Upstream commit f5e7fabd1f5c65b2e077efcdb118cfa67eae7311 ]
Try pinning into VRAM to allow P2P with RDMA NICs without ODP support if all attachments can do P2P. If any attachment can't do P2P just pin into GTT instead.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 25 +++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +18 -7
@@ -75,11 +75,25 @@ static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf,*/ static int amdgpu_dma_buf_pin (struct dma_buf_attachment *attach) { -struct drm_gem_object *obj = attach->dmabuf->priv; -struct amdgpu_bo *bo =gem_to_amdgpu_bo (obj); +struct dma_buf *dmabuf = attach->dmabuf; +struct amdgpu_bo *bo =gem_to_amdgpu_bo (dmabuf->priv); +u32 domains = bo->preferred_domains; -/* pin buffer into GTT */ -return amdgpu_bo_pin (bo,AMDGPU_GEM_DOMAIN_GTT ); +dma_resv_assert_held (dmabuf->resv); + +/* +* Try pinning into VRAM to allow P2P with RDMA NICs without ODP +* support if all attachments can do P2P. If any attachment can't do +* P2P just pin into GTT instead. +*/ +list_for_each_entry (attach, &dmabuf->attachments, node) +if (!attach->peer2peer) + domains &= ~AMDGPU_GEM_DOMAIN_VRAM ; + +if (domains &AMDGPU_GEM_DOMAIN_VRAM ) + bo->flags |=AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ; + +return amdgpu_bo_pin (bo, domains); }/**
@@ -134,9 +148,6 @@ static struct sg_table *amdgpu_dma_buf_map(struct dma_buf_attachment *attach, r =ttm_bo_validate (&bo->tbo, &bo->placement, &ctx);if (r)return ERR_PTR (r); - - }else if (bo->tbo.resource->mem_type !=TTM_PL_TT ) { -return ERR_PTR (-EBUSY ); }switch (bo->tbo.resource->mem_type) {
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 16/34 drm/xe/xe3lpg: Apply Wa_14022293748, Wa_22019794406
In reply to Sasha LevinFrom: Julia Filipchuk <[email protected]>
[ Upstream commit 00e0ae4f1f872800413c819f8a2a909dc29cdc35 ]
Extend Wa_14022293748, Wa_22019794406 to Xe3_LPG
--- drivers/gpu/drm/xe/xe_wa_oob.rules | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/xe/xe_wa_oob.rules +2 -0
@@ -30,8 +30,10 @@ 13011645652 GRAPHICS_VERSION(2004) 14022293748 GRAPHICS_VERSION(2001) GRAPHICS_VERSION(2004) + GRAPHICS_VERSION_RANGE(3000, 3001) 22019794406 GRAPHICS_VERSION(2001) GRAPHICS_VERSION(2004) + GRAPHICS_VERSION_RANGE(3000, 3001) 22019338487 MEDIA_VERSION(2000) GRAPHICS_VERSION(2001) MEDIA_VERSION(3000), MEDIA_STEP(A0, B0), FUNC(xe_rtp_match_not_sriov_vf)
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 17/34 nvme: re-read ANA log page after ns scan completes
In reply to Sasha LevinFrom: Hannes Reinecke <[email protected]>
[ Upstream commit 62baf70c327444338c34703c71aa8cc8e4189bd6 ]
When scanning for new namespaces we might have missed an ANA AEN.
The NVMe base spec (NVMe Base Specification v2.1, Figure 151 'Asynchonous Event Information - Notice': Asymmetric Namespace Access Change) states:
A controller shall not send this even if an Attached Namespace Attribute Changed asynchronous event [...] is sent for the same event.
so we need to re-read the ANA log page after we rescanned the namespace list to update the ANA states of the new namespaces.
--- drivers/nvme/host/core.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/nvme/host/core.c +5 -0
@@ -4296,6 +4296,11 @@ static void nvme_scan_work(struct work_struct *work)/* Requeue if we have missed AENs */ if (test_bit (NVME_AER_NOTICE_NS_CHANGED , &ctrl->events))nvme_queue_scan (ctrl); +#ifdef CONFIG_NVME_MULTIPATH + else +/* Re-read the ANA log page to not miss updates */ + queue_work(nvme_wq, &ctrl->ana_work); +#endif }/*
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 18/34 nvme: multipath: fix return value of nvme_available_path
In reply to Sasha LevinFrom: Uday Shankar <[email protected]>
[ Upstream commit e3105f54a51554fb1bbf19dcaf93c4411d2d6c8a ]
The function returns bool so we should return false, not NULL. No functional changes are expected.
--- drivers/nvme/host/multipath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/multipath.c +1 -1
@@ -427,7 +427,7 @@ static bool nvme_available_path(struct nvme_ns_head *head)struct nvme_ns *ns;if (!test_bit (NVME_NSHEAD_DISK_LIVE , &head->flags)) -return NULL ; +return false;list_for_each_entry_srcu (ns, &head->list, siblings,srcu_read_lock_held (&head->srcu)) {
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 19/34 objtool: Stop UNRET validation on UD2
In reply to Sasha LevinFrom: Josh Poimboeuf <[email protected]>
[ Upstream commit 9f9cc012c2cbac4833746a0182e06a8eec940d19 ]
In preparation for simplifying INSN_SYSCALL, make validate_unret() terminate control flow on UD2 just like validate_branch() already does.
--- tools/objtool/check.c | 3 +++ 1 file changed, 3 insertions(+)
tools/objtool/check.c +3 -0
@@ -3855,6 +3855,9 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn)break ; } +if (insn->dead_end) +return 0 ; +if (!next) {WARN_INSN (insn,"teh end!" );return -1 ;
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 20/34 gpiolib: of: Move Atmel HSMCI quirk up out of the regulator comment
In reply to Sasha LevinFrom: Andy Shevchenko <[email protected]>
[ Upstream commit b8c7a1ac884cc267d1031f8de07f1a689a69fbab ]
The regulator comment in of_gpio_set_polarity_by_property() made on top of a couple of the cases, while Atmel HSMCI quirk is not related to that. Make it clear by moving Atmel HSMCI quirk up out of the scope of the regulator comment.
--- drivers/gpio/gpiolib-of.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpio/gpiolib-of.c +3 -3
@@ -257,6 +257,9 @@ static void of_gpio_set_polarity_by_property(const struct device_node *np, { "fsl,imx8qm-fec", "phy-reset-gpios", "phy-reset-active-high" }, { "fsl,s32v234-fec", "phy-reset-gpios", "phy-reset-active-high" }, #endif +#if IS_ENABLED(CONFIG_MMC_ATMELMCI) + { "atmel,hsmci", "cd-gpios", "cd-inverted" }, +#endif #if IS_ENABLED(CONFIG_PCI_IMX6) { "fsl,imx6q-pcie", "reset-gpio", "reset-gpio-active-high" }, { "fsl,imx6sx-pcie", "reset-gpio", "reset-gpio-active-high" },
@@ -282,9 +285,6 @@ static void of_gpio_set_polarity_by_property(const struct device_node *np, #if IS_ENABLED(CONFIG_REGULATOR_GPIO) { "regulator-gpio", "enable-gpio", "enable-active-high" }, { "regulator-gpio", "enable-gpios", "enable-active-high" }, -#endif -#if IS_ENABLED(CONFIG_MMC_ATMELMCI) - { "atmel,hsmci", "cd-gpios", "cd-inverted" }, #endif }; unsigned int i;
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 21/34 x86/xen: disable CPU idle and frequency drivers for PVH dom0
In reply to Sasha LevinFrom: Roger Pau Monne <[email protected]>
[ Upstream commit 64a66e2c3b3113dc78a6124e14825d68ddc2e188 ]
When running as a PVH dom0 the ACPI tables exposed to Linux are (mostly) the native ones, thus exposing the C and P states, that can lead to attachment of CPU idle and frequency drivers. However the entity in control of the CPU C and P states is Xen, as dom0 doesn't have a full view of the system load, neither has all CPUs assigned and identity pinned.
Like it's done for classic PV guests, prevent Linux from using idle or frequency state drivers when running as a PVH dom0.
On an AMD EPYC 7543P system without this fix a Linux PVH dom0 will keep the host CPUs spinning at 100% even when dom0 is completely idle, as it's attempting to use the acpi_idle driver.
Message-ID: <[email protected]>
--- arch/x86/xen/enlighten_pvh.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
arch/x86/xen/enlighten_pvh.c +18 -1
@@ -1,5 +1,7 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/acpi.h> +#include <linux/cpufreq.h> +#include <linux/cpuidle.h> #include <linux/export.h> #include <linux/mm.h>
@@ -123,8 +125,23 @@ static void __init pvh_arch_setup(void) {pvh_reserve_extra_memory (); -if (xen_initial_domain ()) +if (xen_initial_domain ()) {xen_add_preferred_consoles (); + +/* +* Disable usage of CPU idle and frequency drivers: when +* running as hardware domain the exposed native ACPI tables +* causes idle and/or frequency drivers to attach and +* malfunction. It's Xen the entity that controls the idle and +* frequency states. +* +* For unprivileged domains the exposed ACPI tables are +* fabricated and don't contain such data. +*/ +disable_cpuidle (); +disable_cpufreq (); +WARN_ON (xen_set_default_idle ()); + } }void __init xen_pvh_init (struct boot_params *boot_params)
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 22/34 selftests/mincore: Allow read-ahead pages to reach the end of the file
In reply to Sasha LevinFrom: Qiuxu Zhuo <[email protected]>
[ Upstream commit 197c1eaa7ba633a482ed7588eea6fd4aa57e08d4 ]
When running the mincore_selftest on a system with an XFS file system, it failed the "check_file_mmap" test case due to the read-ahead pages reaching the end of the file. The failure log is as below:
RUN global.check_file_mmap ...
mincore_selftest.c:264:check_file_mmap:Expected i (1024) < vec_size (1024) mincore_selftest.c:265:check_file_mmap:Read-ahead pages reached the end of the file
check_file_mmap: Test failed
FAIL global.check_file_mmap
This is because the read-ahead window size of the XFS file system on this machine is 4 MB, which is larger than the size from the #PF address to the end of the file. As a result, all the pages for this file are populated.
blockdev --getra /dev/nvme0n1p5
8192
blockdev --getbsz /dev/nvme0n1p5
512This issue can be fixed by extending the current FILE_SIZE 4MB to a larger number, but it will still fail if the read-ahead window size of the file system is larger enough. Additionally, in the real world, read-ahead pages reaching the end of the file can happen and is an expected behavior. Therefore, allowing read-ahead pages to reach the end of the file is a better choice for the "check_file_mmap" test case.
--- tools/testing/selftests/mincore/mincore_selftest.c | 3 --- 1 file changed, 3 deletions(-)
tools/testing/selftests/mincore/mincore_selftest.c +0 -3
@@ -261,9 +261,6 @@ TEST(check_file_mmap)TH_LOG ("No read-ahead pages found in memory" ); } - EXPECT_LT(i, vec_size) { -TH_LOG ("Read-ahead pages reached the end of the file" ); - }/* * End of the readahead window. The rest of the pages shouldn't * be in memory.
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 23/34 x86/bugs: Use SBPB in write_ibpb() if applicable
In reply to Sasha LevinFrom: Josh Poimboeuf <[email protected]>
[ Upstream commit fc9fd3f98423367c79e0bd85a9515df26dc1b3cc ]
write_ibpb() does IBPB, which (among other things) flushes branch type predictions on AMD. If the CPU has SRSO_NO, or if the SRSO mitigation has been disabled, branch type flushing isn't needed, in which case the lighter-weight SBPB can be used.
The 'x86_pred_cmd' variable already keeps track of whether IBPB or SBPB should be used. Use that instead of hardcoding IBPB.
--- arch/x86/entry/entry.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/entry/entry.S +1 -1
@@ -18,7 +18,7 @@ SYM_FUNC_START(entry_ibpb) movl $MSR_IA32_PRED_CMD, %ecx - movl $PRED_CMD_IBPB, %eax + movl _ASM_RIP(x86_pred_cmd), %eax xorl %edx, %edx wrmsr
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 24/34 x86/bugs: Don't fill RSB on VMEXIT with eIBRS+retpoline
In reply to Sasha LevinFrom: Josh Poimboeuf <[email protected]>
[ Upstream commit 18bae0dfec15b24ec14ca17dc18603372f5f254f ]
eIBRS protects against guest->host RSB underflow/poisoning attacks. Adding retpoline to the mix doesn't change that. Retpoline has a balanced CALL/RET anyway.
So the current full RSB filling on VMEXIT with eIBRS+retpoline is overkill. Disable it or do the VMEXIT_LITE mitigation if needed.
--- arch/x86/kernel/cpu/bugs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/bugs.c +4 -4
@@ -1604,20 +1604,20 @@ static void __init spectre_v2_determine_rsb_fill_type_at_vmexit(enum spectre_v2_case SPECTRE_V2_NONE :return ; -case SPECTRE_V2_EIBRS_LFENCE :case SPECTRE_V2_EIBRS : +case SPECTRE_V2_EIBRS_LFENCE : +case SPECTRE_V2_EIBRS_RETPOLINE :if (boot_cpu_has_bug (X86_BUG_EIBRS_PBRSB )) { -setup_force_cpu_cap (X86_FEATURE_RSB_VMEXIT_LITE );pr_info ("Spectre v2 / PBRSB-eIBRS: Retire a single CALL on VMEXIT\n" ); +setup_force_cpu_cap (X86_FEATURE_RSB_VMEXIT_LITE ); }return ; -case SPECTRE_V2_EIBRS_RETPOLINE :case SPECTRE_V2_RETPOLINE :case SPECTRE_V2_LFENCE :case SPECTRE_V2_IBRS : -setup_force_cpu_cap (X86_FEATURE_RSB_VMEXIT );pr_info ("Spectre v2 / SpectreRSB : Filling RSB on VMEXIT\n" ); +setup_force_cpu_cap (X86_FEATURE_RSB_VMEXIT );return ; }
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 25/34 x86/bugs: Don't fill RSB on context switch with eIBRS
In reply to Sasha LevinFrom: Josh Poimboeuf <[email protected]>
[ Upstream commit 27ce8299bc1ec6df8306073785ff82b30b3cc5ee ]
User->user Spectre v2 attacks (including RSB) across context switches are already mitigated by IBPB in cond_mitigation(), if enabled globally or if either the prev or the next task has opted in to protection. RSB filling without IBPB serves no purpose for protecting user space, as indirect branches are still vulnerable.
User->kernel RSB attacks are mitigated by eIBRS. In which case the RSB filling on context switch isn't needed, so remove it.
--- arch/x86/kernel/cpu/bugs.c | 24 ++++++++++++------------ arch/x86/mm/tlb.c | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-)
arch/x86/kernel/cpu/bugs.c +12 -12
@@ -1578,7 +1578,7 @@ static void __init spec_ctrl_disable_kernel_rrsba(void) rrsba_disabled = true; } -static void __init spectre_v2_determine_rsb_fill_type_at_vmexit (enum spectre_v2_mitigation mode) +static void __init spectre_v2_select_rsb_mitigation (enum spectre_v2_mitigation mode) {/* * Similar to context switches, there are two types of RSB attacks
@@ -1602,7 +1602,7 @@ static void __init spectre_v2_determine_rsb_fill_type_at_vmexit(enum spectre_v2_*/ switch (mode) {case SPECTRE_V2_NONE : -return ; +break ;case SPECTRE_V2_EIBRS :case SPECTRE_V2_EIBRS_LFENCE :
@@ -1611,18 +1611,21 @@ static void __init spectre_v2_determine_rsb_fill_type_at_vmexit(enum spectre_v2_pr_info ("Spectre v2 / PBRSB-eIBRS: Retire a single CALL on VMEXIT\n" );setup_force_cpu_cap (X86_FEATURE_RSB_VMEXIT_LITE ); } -return ; +break ;case SPECTRE_V2_RETPOLINE :case SPECTRE_V2_LFENCE :case SPECTRE_V2_IBRS : -pr_info ("Spectre v2 / SpectreRSB : Filling RSB on VMEXIT\n" ); +pr_info ("Spectre v2 / SpectreRSB: Filling RSB on context switch and VMEXIT\n" ); +setup_force_cpu_cap (X86_FEATURE_RSB_CTXSW );setup_force_cpu_cap (X86_FEATURE_RSB_VMEXIT ); -return ; - } +break ; -pr_warn_once ("Unknown Spectre v2 mode, disabling RSB mitigation at VM exit" ); -dump_stack (); +default : +pr_warn_once ("Unknown Spectre v2 mode, disabling RSB mitigation\n" ); +dump_stack (); +break ; + } }/*
@@ -1854,10 +1857,7 @@ static void __init spectre_v2_select_mitigation(void)* * FIXME: Is this pointless for retbleed-affected AMD? */ -setup_force_cpu_cap (X86_FEATURE_RSB_CTXSW ); -pr_info ("Spectre v2 / SpectreRSB mitigation: Filling RSB on context switch\n" ); - -spectre_v2_determine_rsb_fill_type_at_vmexit (mode); +spectre_v2_select_rsb_mitigation (mode);/* * Retpoline protects the kernel, but doesn't protect firmware. IBRS
arch/x86/mm/tlb.c +3 -3
@@ -389,9 +389,9 @@ static void cond_mitigation(struct task_struct *next) prev_mm =this_cpu_read (cpu_tlbstate.last_user_mm_spec);/* -* Avoid user/user BTB poisoning by flushing the branch predictor -* when switching between processes. This stops one process from -* doing Spectre-v2 attacks on another. +* Avoid user->user BTB/RSB poisoning by flushing them when switching +* between processes. This stops one process from doing Spectre-v2 +* attacks on another. * * Both, the conditional and the always IBPB mode use the mm * pointer to avoid the IBPB when switching between tasks of the
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 26/34 nvmet-fc: take tgtport reference only once
In reply to Sasha LevinFrom: Daniel Wagner <[email protected]>
[ Upstream commit b0b26ad0e1943de25ce82a7e5af3574f31b1cf99 ]
The reference counting code can be simplified. Instead taking a tgtport refrerence at the beginning of nvmet_fc_alloc_hostport and put it back if not a new hostport object is allocated, only take it when a new hostport object is allocated.
--- drivers/nvme/target/fc.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-)
drivers/nvme/target/fc.c +7 -15
@@ -1042,33 +1042,24 @@ nvmet_fc_alloc_hostport(struct nvmet_fc_tgtport *tgtport, void *hosthandle)struct nvmet_fc_hostport *newhost, *match =NULL ;unsigned long flags; +/* +* Caller holds a reference on tgtport. +*/ +/* if LLDD not implemented, leave as NULL */ if (!hosthandle)return NULL ; -/* -* take reference for what will be the newly allocated hostport if -* we end up using a new allocation -*/ -if (!nvmet_fc_tgtport_get (tgtport)) -return ERR_PTR (-EINVAL ); -spin_lock_irqsave (&tgtport->lock, flags); match =nvmet_fc_match_hostport (tgtport, hosthandle);spin_unlock_irqrestore (&tgtport->lock, flags); -if (match) { -/* no new allocation - release reference */ -nvmet_fc_tgtport_put (tgtport); +if (match)return match; - } newhost =kzalloc (sizeof (*newhost),GFP_KERNEL ); -if (!newhost) { -/* no new allocation - release reference */ -nvmet_fc_tgtport_put (tgtport); +if (!newhost)return ERR_PTR (-ENOMEM ); - }spin_lock_irqsave (&tgtport->lock, flags); match =nvmet_fc_match_hostport (tgtport, hosthandle);
@@ -1077,6 +1068,7 @@ nvmet_fc_alloc_hostport(struct nvmet_fc_tgtport *tgtport, void *hosthandle)kfree (newhost); newhost = match; }else { +nvmet_fc_tgtport_get (tgtport); newhost->tgtport = tgtport; newhost->hosthandle = hosthandle;INIT_LIST_HEAD (&newhost->host_list);
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 27/34 nvmet-fc: put ref when assoc->del_work is already scheduled
In reply to Sasha LevinFrom: Daniel Wagner <[email protected]>
[ Upstream commit 70289ae5cac4d3a39575405aaf63330486cea030 ]
Do not leak the tgtport reference when the work is already scheduled.
--- drivers/nvme/target/fc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/target/fc.c +2 -1
@@ -1103,7 +1103,8 @@ static void nvmet_fc_schedule_delete_assoc(struct nvmet_fc_tgt_assoc *assoc) {nvmet_fc_tgtport_get (assoc->tgtport); -queue_work (nvmet_wq, &assoc->del_work); +if (!queue_work (nvmet_wq, &assoc->del_work)) +nvmet_fc_tgtport_put (assoc->tgtport); } static bool
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 28/34 net_sched: sch_sfq: use a temporary work area for validating configuration
In reply to Sasha LevinFrom: Octavian Purdila <[email protected]>
[ Upstream commit 8c0cea59d40cf6dd13c2950437631dd614fbade6 ]
Many configuration parameters have influence on others (e.g. divisor -> flows -> limit, depth -> limit) and so it is difficult to correctly do all of the validation before applying the configuration. And if a validation error is detected late it is difficult to roll back a partially applied configuration.
To avoid these issues use a temporary work area to update and validate the configuration and only then apply the configuration to the internal state.
--- net/sched/sch_sfq.c | 56 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 12 deletions(-)
net/sched/sch_sfq.c +44 -12
@@ -631,6 +631,15 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt,struct red_parms *p =NULL ;struct sk_buff *to_free =NULL ;struct sk_buff *tail =NULL ; +unsigned int maxflows; +unsigned int quantum; +unsigned int divisor; +int perturb_period; +u8 headdrop; +u8 maxdepth; +int limit; +u8 flags; +if (opt->nla_len <nla_attr_size (sizeof (*ctl)))return -EINVAL ;
@@ -656,36 +665,59 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt,NL_SET_ERR_MSG_MOD (extack,"invalid limit" );return -EINVAL ; } +sch_tree_lock (sch); + + limit = q->limit; + divisor = q->divisor; + headdrop = q->headdrop; + maxdepth = q->maxdepth; + maxflows = q->maxflows; + perturb_period = q->perturb_period; + quantum = q->quantum; + flags = q->flags; + +/* update and validate configuration */ if (ctl->quantum) - q->quantum = ctl->quantum; -WRITE_ONCE (q->perturb_period, ctl->perturb_period *HZ ); + quantum = ctl->quantum; + perturb_period = ctl->perturb_period *HZ ;if (ctl->flows) - q->maxflows =min_t (u32, ctl->flows,SFQ_MAX_FLOWS ); + maxflows =min_t (u32, ctl->flows,SFQ_MAX_FLOWS );if (ctl->divisor) { - q->divisor = ctl->divisor; - q->maxflows =min_t (u32, q->maxflows, q->divisor); + divisor = ctl->divisor; + maxflows =min_t (u32, maxflows, divisor); }if (ctl_v1) {if (ctl_v1->depth) - q->maxdepth =min_t (u32, ctl_v1->depth,SFQ_MAX_DEPTH ); + maxdepth =min_t (u32, ctl_v1->depth,SFQ_MAX_DEPTH );if (p) { -swap (q->red_parms, p); -red_set_parms (q->red_parms, +red_set_parms (p, ctl_v1->qth_min, ctl_v1->qth_max, ctl_v1->Wlog, ctl_v1->Plog, ctl_v1->Scell_log,NULL , ctl_v1->max_P); } - q->flags = ctl_v1->flags; - q->headdrop = ctl_v1->headdrop; + flags = ctl_v1->flags; + headdrop = ctl_v1->headdrop; }if (ctl->limit) { - q->limit =min_t (u32, ctl->limit, q->maxdepth * q->maxflows); - q->maxflows =min_t (u32, q->maxflows, q->limit); + limit =min_t (u32, ctl->limit, maxdepth * maxflows); + maxflows =min_t (u32, maxflows, limit); } +/* commit configuration */ + q->limit = limit; + q->divisor = divisor; + q->headdrop = headdrop; + q->maxdepth = maxdepth; + q->maxflows = maxflows; +WRITE_ONCE (q->perturb_period, perturb_period); + q->quantum = quantum; + q->flags = flags; +if (p) +swap (q->red_parms, p); + qlen = sch->q.qlen;while (sch->q.qlen > q->limit) { dropped +=sfq_drop (sch, &to_free);
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 29/34 cifs: Fix encoding of SMB1 Session Setup Kerberos Request in non-UNICODE mode
In reply to Sasha LevinFrom: Pali Rohár <[email protected]>
[ Upstream commit 16cb6b0509b65ac89187e9402e0b7a9ddf1765ef ]
Like in UNICODE mode, SMB1 Session Setup Kerberos Request contains oslm and domain strings.
Extract common code into ascii_oslm_strings() and ascii_domain_string() functions (similar to unicode variants) and use these functions in non-UNICODE code path in sess_auth_kerberos().
Decision if non-UNICODE or UNICODE mode is used is based on the SMBFLG2_UNICODE flag in Flags2 packed field, and not based on the capabilities of server. Fix this check too.
--- fs/smb/client/sess.c | 60 +++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 20 deletions(-)
fs/smb/client/sess.c +40 -20
@@ -672,6 +672,22 @@ unicode_oslm_strings(char **pbcc_area, const struct nls_table *nls_cp) *pbcc_area = bcc_ptr; } +static void +ascii_oslm_strings (char **pbcc_area,const struct nls_table *nls_cp) +{ +char *bcc_ptr = *pbcc_area; + +strcpy (bcc_ptr,"Linux version " ); + bcc_ptr +=strlen ("Linux version " ); +strcpy (bcc_ptr,init_utsname ()->release); + bcc_ptr +=strlen (init_utsname ()->release) +1 ; + +strcpy (bcc_ptr,CIFS_NETWORK_OPSYS ); + bcc_ptr +=strlen (CIFS_NETWORK_OPSYS ) +1 ; + + *pbcc_area = bcc_ptr; +} +static void unicode_domain_string (char **pbcc_area,struct cifs_ses *ses,const struct nls_table *nls_cp) {
@@ -696,6 +712,25 @@ static void unicode_domain_string(char **pbcc_area, struct cifs_ses *ses, *pbcc_area = bcc_ptr; } +static void ascii_domain_string (char **pbcc_area,struct cifs_ses *ses, +const struct nls_table *nls_cp) +{ +char *bcc_ptr = *pbcc_area; +int len; + +/* copy domain */ +if (ses->domainName !=NULL ) { + len =strscpy (bcc_ptr, ses->domainName,CIFS_MAX_DOMAINNAME_LEN ); +if (WARN_ON_ONCE (len <0 )) + len =CIFS_MAX_DOMAINNAME_LEN -1 ; + bcc_ptr += len; + }/* else we send a null domain name so server will default to its own domain */ + *bcc_ptr =0 ; + bcc_ptr++; + + *pbcc_area = bcc_ptr; +} +static void unicode_ssetup_strings (char **pbcc_area,struct cifs_ses *ses,const struct nls_table *nls_cp) {
@@ -741,25 +776,10 @@ static void ascii_ssetup_strings(char **pbcc_area, struct cifs_ses *ses, *bcc_ptr =0 ; bcc_ptr++;/* account for null termination */ -/* copy domain */ -if (ses->domainName !=NULL ) { - len =strscpy (bcc_ptr, ses->domainName,CIFS_MAX_DOMAINNAME_LEN ); -if (WARN_ON_ONCE (len <0 )) - len =CIFS_MAX_DOMAINNAME_LEN -1 ; - bcc_ptr += len; - }/* else we send a null domain name so server will default to its own domain */ - *bcc_ptr =0 ; - bcc_ptr++; -/* BB check for overflow here */ -strcpy (bcc_ptr,"Linux version " ); - bcc_ptr +=strlen ("Linux version " ); -strcpy (bcc_ptr,init_utsname ()->release); - bcc_ptr +=strlen (init_utsname ()->release) +1 ; - -strcpy (bcc_ptr,CIFS_NETWORK_OPSYS ); - bcc_ptr +=strlen (CIFS_NETWORK_OPSYS ) +1 ; +ascii_domain_string (&bcc_ptr, ses, nls_cp); +ascii_oslm_strings (&bcc_ptr, nls_cp); *pbcc_area = bcc_ptr; }
@@ -1562,7 +1582,7 @@ sess_auth_kerberos(struct sess_data *sess_data) sess_data->iov[1 ].iov_len = msg->secblob_len; pSMB->req.SecurityBlobLength =cpu_to_le16 (sess_data->iov[1 ].iov_len); -if (ses->capabilities &CAP_UNICODE ) { +if (pSMB->req.hdr.Flags2 &SMBFLG2_UNICODE ) {/* unicode strings must be word aligned */ if (!IS_ALIGNED (sess_data->iov[0 ].iov_len + sess_data->iov[1 ].iov_len,2 )) { *bcc_ptr =0 ;
@@ -1571,8 +1591,8 @@ sess_auth_kerberos(struct sess_data *sess_data)unicode_oslm_strings (&bcc_ptr, sess_data->nls_cp);unicode_domain_string (&bcc_ptr, ses, sess_data->nls_cp); }else { -/* BB: is this right? */ -ascii_ssetup_strings (&bcc_ptr, ses, sess_data->nls_cp); +ascii_oslm_strings (&bcc_ptr, sess_data->nls_cp); +ascii_domain_string (&bcc_ptr, ses, sess_data->nls_cp); } sess_data->iov[2].iov_len = (long) bcc_ptr -
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 30/34 timekeeping: Add a lockdep override in tick_freeze()
In reply to Sasha LevinFrom: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 92e250c624ea37fde64bfd624fd2556f0d846f18 ]
tick_freeze() acquires a raw spinlock (tick_freeze_lock). Later in the callchain (timekeeping_suspend() -> mc146818_avoid_UIP()) the RTC driver acquires a spinlock which becomes a sleeping lock on PREEMPT_RT. Lockdep complains about this lock nesting.
Add a lockdep override for this special case and a comment explaining why it is okay.
--- kernel/time/tick-common.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
kernel/time/tick-common.c +22 -0
@@ -509,6 +509,7 @@ void tick_resume(void)#ifdef CONFIG_SUSPEND static DEFINE_RAW_SPINLOCK (tick_freeze_lock); +static DEFINE_WAIT_OVERRIDE_MAP(tick_freeze_map, LD_WAIT_SLEEP);static unsigned int tick_freeze_depth;/**
@@ -528,9 +529,22 @@ void tick_freeze(void)if (tick_freeze_depth ==num_online_cpus ()) {trace_suspend_resume (TPS ("timekeeping_freeze" ),smp_processor_id (), true); +/* +* All other CPUs have their interrupts disabled and are +* suspended to idle. Other tasks have been frozen so there +* is no scheduling happening. This means that there is no +* concurrency in the system at this point. Therefore it is +* okay to acquire a sleeping lock on PREEMPT_RT, such as a +* spinlock, because the lock cannot be held by other CPUs +* or threads and acquiring it cannot block. +* +* Inform lockdep about the situation. +*/ +lock_map_acquire_try (&tick_freeze_map); system_state =SYSTEM_SUSPEND ;sched_clock_suspend ();timekeeping_suspend (); +lock_map_release (&tick_freeze_map); }else {tick_suspend_local (); }
@@ -552,8 +566,16 @@ void tick_unfreeze(void)raw_spin_lock (&tick_freeze_lock);if (tick_freeze_depth ==num_online_cpus ()) { +/* +* Similar to tick_freeze(). On resumption the first CPU may +* acquire uncontended sleeping locks while other CPUs block on +* tick_freeze_lock. +*/ +lock_map_acquire_try (&tick_freeze_map);timekeeping_resume ();sched_clock_resume (); +lock_map_release (&tick_freeze_map); + system_state =SYSTEM_RUNNING ;trace_suspend_resume (TPS ("timekeeping_freeze" ),smp_processor_id (), false);
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 31/34 cifs: Fix querying of WSL CHR and BLK reparse points over SMB1
In reply to Sasha LevinFrom: Pali Rohár <[email protected]>
[ Upstream commit ef86ab131d9127dfbfa8f06e12441d05fdfb090b ]
When reparse point in SMB1 query_path_info() callback was detected then query also for EA $LXDEV. In this EA are stored device major and minor numbers used by WSL CHR and BLK reparse points. Without major and minor numbers, stat() syscall does not work for char and block devices.
Similar code is already in SMB2+ query_path_info() callback function.
--- fs/smb/client/smb1ops.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
fs/smb/client/smb1ops.c +36 -0
@@ -573,6 +573,42 @@ static int cifs_query_path_info(const unsigned int xid, data->reparse_point =le32_to_cpu (fi.Attributes) &ATTR_REPARSE ; } +#ifdef CONFIG_CIFS_XATTR +/* +* For WSL CHR and BLK reparse points it is required to fetch +* EA $LXDEV which contains major and minor device numbers. +*/ +if (!rc && data->reparse_point) { +struct smb2_file_full_ea_info *ea; + + ea = (struct smb2_file_full_ea_info *)data->wsl.eas; + rc =CIFSSMBQAllEAs (xid, tcon, full_path,SMB2_WSL_XATTR_DEV , + &ea->ea_data[SMB2_WSL_XATTR_NAME_LEN +1 ], +SMB2_WSL_XATTR_DEV_SIZE , cifs_sb); +if (rc ==SMB2_WSL_XATTR_DEV_SIZE ) { + ea->next_entry_offset =cpu_to_le32 (0 ); + ea->flags =0 ; + ea->ea_name_length =SMB2_WSL_XATTR_NAME_LEN ; + ea->ea_value_length =cpu_to_le16 (SMB2_WSL_XATTR_DEV_SIZE ); +memcpy (&ea->ea_data[0 ],SMB2_WSL_XATTR_DEV ,SMB2_WSL_XATTR_NAME_LEN +1 ); + data->wsl.eas_len =sizeof (*ea) +SMB2_WSL_XATTR_NAME_LEN +1 + +SMB2_WSL_XATTR_DEV_SIZE ; + rc =0 ; + }else if (rc >=0 ) { +/* It is an error if EA $LXDEV has wrong size. */ + rc = -EINVAL ; + }else { +/* +* In all other cases ignore error if fetching +* of EA $LXDEV failed. It is needed only for +* WSL CHR and BLK reparse points and wsl_to_fattr() +* handle the case when EA is missing. +*/ + rc =0 ; + } + } +#endif +return rc; }
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 32/34 net: phy: move phy_link_change() prior to mdio_bus_phy_may_suspend()
In reply to Sasha LevinFrom: Vladimir Oltean <[email protected]>
[ Upstream commit f40a673d6b4a128fe95dd9b8c3ed02da50a6a862 ]
In an upcoming change, mdio_bus_phy_may_suspend() will need to distinguish a phylib-based PHY client from a phylink PHY client. For that, it will need to compare the phydev->phy_link_change() function pointer with the eponymous phy_link_change() provided by phylib.
To avoid forward function declarations, the default PHY link state change method should be moved upwards. There is no functional change associated with this patch, it is only to reduce the noise from a real bug fix.
--- drivers/net/phy/phy_device.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/net/phy/phy_device.c +13 -13
@@ -240,6 +240,19 @@ static bool phy_drv_wol_enabled(struct phy_device *phydev)return wol.wolopts !=0 ; } +static void phy_link_change (struct phy_device *phydev,bool up) +{ +struct net_device *netdev = phydev->attached_dev; + +if (up) +netif_carrier_on (netdev); +else +netif_carrier_off (netdev); + phydev->adjust_link (netdev); +if (phydev->mii_ts && phydev->mii_ts->link_state) + phydev->mii_ts->link_state (phydev->mii_ts, phydev); +} +static bool mdio_bus_phy_may_suspend (struct phy_device *phydev) {struct device_driver *drv = phydev->mdio.dev.driver;
@@ -1052,19 +1065,6 @@ struct phy_device *phy_find_first(struct mii_bus *bus) }EXPORT_SYMBOL (phy_find_first); -static void phy_link_change (struct phy_device *phydev,bool up) -{ -struct net_device *netdev = phydev->attached_dev; - -if (up) -netif_carrier_on (netdev); -else -netif_carrier_off (netdev); - phydev->adjust_link (netdev); -if (phydev->mii_ts && phydev->mii_ts->link_state) - phydev->mii_ts->link_state (phydev->mii_ts, phydev); -} -/** * phy_prepare_link - prepares the PHY layer to monitor link status * @phydev: target phy_device struct
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 33/34 iommu: Clear iommu-dma ops on cleanup
In reply to Sasha LevinFrom: Robin Murphy <[email protected]>
[ Upstream commit 280e5a30100578106a4305ce0118e0aa9b866f12 ]
If iommu_device_register() encounters an error, it can end up tearing down already-configured groups and default domains, however this currently still leaves devices hooked up to iommu-dma (and even historically the behaviour in this area was at best inconsistent across architectures/drivers...) Although in the case that an IOMMU is present whose driver has failed to probe, users cannot necessarily expect DMA to work anyway, it's still arguable that we should do our best to put things back as if the IOMMU driver was never there at all, and certainly the potential for crashing in iommu-dma itself is undesirable. Make sure we clean up the dev->dma_iommu flag along with everything else.
--- drivers/iommu/iommu.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iommu/iommu.c +3 -0
@@ -508,6 +508,9 @@ static void iommu_deinit_device(struct device *dev) dev->iommu_group =NULL ;module_put (ops->owner);dev_iommu_free (dev); +#ifdef CONFIG_IOMMU_DMA + dev->dma_iommu = false; +#endif }DEFINE_MUTEX (iommu_probe_device_lock);
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 34/34 ext4: make block validity check resistent to sb bh corruption
In reply to Sasha LevinFrom: Ojaswin Mujoo <[email protected]>
[ Upstream commit ccad447a3d331a239477c281533bacb585b54a98 ]
Block validity checks need to be skipped in case they are called for journal blocks since they are part of system's protected zone.
Currently, this is done by checking inode->ino against sbi->s_es->s_journal_inum, which is a direct read from the ext4 sb buffer head. If someone modifies this underneath us then the s_journal_inum field might get corrupted. To prevent against this, change the check to directly compare the inode with journal->j_inode.
**Slight change in behavior**: During journal init path, check_block_validity etc might be called for journal inode when sbi->s_journal is not set yet. In this case we now proceed with ext4_inode_block_valid() instead of returning early. Since systems zones have not been set yet, it is okay to proceed so we can perform basic checks on the blocks.
--- fs/ext4/block_validity.c | 5 ++--- fs/ext4/inode.c | 7 ++++--- 2 files changed, 6 insertions(+), 6 deletions(-)
fs/ext4/block_validity.c +2 -3
@@ -351,10 +351,9 @@ int ext4_check_blockref(const char *function, unsigned int line, {__le32 *bref = p;unsigned int blk; +journal_t *journal =EXT4_SB (inode->i_sb)->s_journal; -if (ext4_has_feature_journal (inode->i_sb) && - (inode->i_ino == -le32_to_cpu (EXT4_SB (inode->i_sb)->s_es->s_journal_inum))) +if (journal && inode == journal->j_inode)return 0 ;while (bref < p+max) {
fs/ext4/inode.c +4 -3
@@ -383,10 +383,11 @@ static int __check_block_validity(struct inode *inode, const char *func,unsigned int line, struct ext4_map_blocks *map) { - if (ext4_has_feature_journal(inode->i_sb) && - (inode->i_ino == - le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_journal_inum))) + journal_t *journal = EXT4_SB(inode->i_sb)->s_journal; + +if (journal && inode == journal->j_inode)return 0 ; +if (!ext4_inode_block_valid (inode, map->m_pblk, map->m_len)) {ext4_error_inode (inode, func, line, map->m_pblk, "lblock %lu mapped to illegal pblock %llu "
Signature · 1 line
2.39.5
Re: [PATCH AUTOSEL 6.14 15/34] drm/amdgpu: allow pinning DMA-bufs into VRAM if all importers can do P2P
In reply to Sasha LevinQuoted 9 lines · Sasha Levin
From: Christian König <[email protected]>
[ Upstream commit
f5e7fabd1f5c65b2e077efcdb118cfa67eae7311]Try pinning into VRAM to allow P2P with RDMA NICs without ODP support if all attachments can do P2P. If any attachment can't do P2P just pin into GTT instead.
Quoted 8 lines
Acked-by Simona Vetter <[email protected]>Signed-off-by Christian König <[email protected]>Signed-off-by Felix Kuehling <[email protected]>Reviewed-by Felix Kuehling <[email protected]>Tested-by Pak Nin Lui <[email protected]>Cc Simona Vetter <[email protected]>Signed-off-by Alex Deucher <[email protected]>Signed-off-by Sasha Levin <[email protected]>
This should not go to stable. It depends on dmem cgroups.
Alex
Quoted 51 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 25 +++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +18
-8@@ -75,11 +75,25 @@ static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf,*/ static int amdgpu_dma_buf_pin (struct dma_buf_attachment *attach) { -struct drm_gem_object *obj = attach->dmabuf->priv; -struct amdgpu_bo *bo =gem_to_amdgpu_bo (obj); +struct dma_buf *dmabuf = attach->dmabuf; +struct amdgpu_bo *bo =gem_to_amdgpu_bo (dmabuf->priv); +u32 domains = bo->preferred_domains; -/* pin buffer into GTT */ -return amdgpu_bo_pin (bo,AMDGPU_GEM_DOMAIN_GTT ); +dma_resv_assert_held (dmabuf->resv); + +/* +* Try pinning into VRAM to allow P2P with RDMA NICs without ODP +* support if all attachments can do P2P. If any attachment can't do +* P2P just pin into GTT instead. +*/ +list_for_each_entry (attach, &dmabuf->attachments, node) +if (!attach->peer2peer) + domains &= ~AMDGPU_GEM_DOMAIN_VRAM ; + +if (domains &AMDGPU_GEM_DOMAIN_VRAM ) + bo->flags |=AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ; + +return amdgpu_bo_pin (bo, domains); }/** @@ -134,9 +148,6 @@ static struct sg_table *amdgpu_dma_buf_map(struct dma_buf_attachment *attach, r =ttm_bo_validate (&bo->tbo, &bo->placement, &ctx);if (r)return ERR_PTR (r); - - }else if (bo->tbo.resource->mem_type !=TTM_PL_TT ) { -return ERR_PTR (-EBUSY ); }switch (bo->tbo.resource->mem_type) { --2.39.5