Skip to content

Commit 832ef87

Browse files
xiongmengbiaoAvenger-285714
authored andcommitted
drivers/crypto/ccp: fix soft lockup warning in psp_mutex_lock_timeout()
hygon inclusion category: bugfix CVE: NA --------------------------- When psp_do_cmd try lock mutex timeout, the following error may occur: [ 544.294573] watchdog: BUG: soft lockup - CPU#30 stuck for 26s! [hwrng:1063] [ 544.295235] Modules linked in: hct nf_conntrack_netlink nfnetlink xt_addrtype xt_CHECKSUM xt_MASQUERADE xt_conntrack ipt_REJECT nf_reject_ipv4 dm_mod ip6table_mangle ip6table_nat ip6table_filter ip6_tables iptable_mangle iptable_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c iptable_filter ip_tables rfkill overlay sunrpc vfat fat intel_rapl_msr intel_rapl_common amd64_edac edac_mce_amd kvm_amd ipmi_ssif joydev kvm sg pcspkr acpi_ipmi ipmi_si rapl k10temp i2c_piix4 i2c_designware_platform acpi_cpufreq ipmi_devintf tpm_hygon ipmi_msghandler i2c_designware_core ext4 mbcache jbd2 sd_mod t10_pi crc64_rocksoft_generic crc64_rocksoft crc64 crct10dif_pclmul ahci crc32_pclmul libahci crc32c_intel ast polyval_clmulni drm_shmem_helper drm_kms_helper polyval_generic ixgbe ghash_clmulni_intel igb mdio ccp sha512_ssse3 i2c_algo_bit dca drm libata mdev sp5100_tco sm4 vhost_net tun tap vhost_vsock vmw_vsock_virtio_transport_common vsock vhost vhost_iotlb vfio_pci vfio_pci_core irqbypass vfio_iommu_type1 vfio fuse [ 544.295390] br_netfilter bridge stp llc [ 544.300301] CPU: 30 PID: 1063 Comm: hwrng Kdump: loaded Not tainted 6.6.7-hygon #2 [ 544.300828] Hardware name: HYGON Hygon35N16/35N16, BIOS A0273036 05/31/2024 [ 544.301367] RIP: 0010:psp_do_cmd+0x57/0x100 [ccp] [ 544.301936] Code: 48 8b 05 fc 8c a6 f2 48 8d 88 60 ea 00 00 48 8b 05 d6 d7 00 00 48 8b 50 08 48 c7 44 24 08 01 00 00 00 48 8b 44 24 08 48 87 02 <48> 89 44 24 08 48 8b 44 24 08 48 85 c0 74 4b 48 8b 05 c3 8c a6 f2 [ 544.303086] RSP: 0018:ffffc9000920fd30 EFLAGS: 00000283 [ 544.303674] RAX: 0000000000000001 RBX: 0000000000000100 RCX: 0000000100043a60 [ 544.304279] RDX: ffff888180a04000 RSI: ffff888144422028 RDI: 0000000000000100 [ 544.304891] RBP: ffff888144422028 R08: ffffc9000920fdd0 R09: ffff8890a1dfd006 [ 544.305508] R10: 40007b0100000c00 R11: 00000c0000000180 R12: ffffc9000920fd64 [ 544.306133] R13: ffff8890a1dfd000 R14: 000000007b010000 R15: ffff888146c75000 [ 544.306756] FS: 0000000000000000(0000) GS:ffff88985e380000(0000) knlGS:0000000000000000 [ 544.307397] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 544.308042] CR2: 00007f9392a6f830 CR3: 000000011441c000 CR4: 00000000003506e0 [ 544.308696] Call Trace: [ 544.309361] <IRQ> [ 544.310020] ? watchdog_timer_fn+0x1b4/0x220 [ 544.310693] ? __pfx_watchdog_timer_fn+0x10/0x10 [ 544.311365] ? __hrtimer_run_queues+0x112/0x2b0 [ 544.312046] ? hrtimer_interrupt+0xf4/0x230 [ 544.312732] ? __sysvec_apic_timer_interrupt+0x4c/0x140 [ 544.313421] ? sysvec_apic_timer_interrupt+0x69/0x90 [ 544.314115] </IRQ> [ 544.314752] <TASK> [ 544.315384] ? asm_sysvec_apic_timer_interrupt+0x16/0x20 [ 544.316036] ? psp_do_cmd+0x57/0x100 [ccp] [ 544.316699] tpm_c_send+0x46/0x90 [tpm_hygon] [ 544.317345] tpm_try_transmit+0x62/0x2a0 [ 544.317992] tpm_transmit+0x8e/0x290 [ 544.318623] tpm_transmit_cmd+0x25/0xa0 [ 544.319247] tpm2_get_random+0xea/0x1e0 [ 544.319872] ? __pfx_hwrng_fillfn+0x10/0x10 [ 544.320496] tpm_get_random+0x5b/0x70 [ 544.321115] hwrng_fillfn+0xde/0x1e0 [ 544.321731] kthread+0xe4/0x110 [ 544.322346] ? __pfx_kthread+0x10/0x10 [ 544.322961] ret_from_fork+0x30/0x50 [ 544.323570] ? __pfx_kthread+0x10/0x10 [ 544.324141] ret_from_fork_asm+0x1b/0x30 [ 544.324711] </TASK> Fixes: 75f7390 ("drivers/crypto/ccp: concurrent psp access support between user and kernel space") Signed-off-by: xiongmengbiao <[email protected]>
1 parent ff7b915 commit 832ef87

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/crypto/ccp/hygon/psp-dev.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,21 @@ int psp_mutex_trylock(struct psp_mutex *mutex)
7575
int psp_mutex_lock_timeout(struct psp_mutex *mutex, uint64_t ms)
7676
{
7777
int ret = 0;
78-
unsigned long je;
78+
unsigned long je, last_je;
7979

80+
last_je = jiffies;
8081
je = jiffies + msecs_to_jiffies(ms);
8182
do {
8283
if (psp_mutex_trylock(mutex)) {
8384
ret = 1;
8485
break;
8586
}
87+
88+
// avoid triggering soft lockup warning
89+
if (time_after(jiffies, last_je + msecs_to_jiffies(100))) {
90+
schedule();
91+
last_je = jiffies;
92+
}
8693
} while ((ms == 0) || time_before(jiffies, je));
8794

8895
return ret;

0 commit comments

Comments
 (0)