* [PATCH 1/1] x86/split_lock: add the source of exception to warning logs
@ 2024-02-23 9:47 Dongli Zhang
2024-02-23 16:27 ` Dave Hansen
0 siblings, 1 reply; 3+ messages in thread
From: Dongli Zhang @ 2024-02-23 9:47 UTC (permalink / raw)
To: x86; +Cc: tglx, mingo, bp, dave.hansen, hpa, linux-kernel, joe.jin
Currently to trigger split lock exception at the guest side will print the
below to host logs.
"x86/split lock detection: #AC: CPU 1/KVM/65886 took a split_lock trap at
address: 0x401173"
Although it is more likely the split lock exception is from the guest side,
differentiate if it is from the guest side, or the host userspace
VMM (e.g., QEMU).
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
arch/x86/kernel/cpu/intel.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index a927a8fc9624..22285e7cc138 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -1155,14 +1155,15 @@ static int splitlock_cpu_offline(unsigned int cpu)
return 0;
}
-static void split_lock_warn(unsigned long ip)
+static void split_lock_warn(unsigned long ip, bool is_guest)
{
struct delayed_work *work;
int cpu;
if (!current->reported_split_lock)
- pr_warn_ratelimited("#AC: %s/%d took a split_lock trap at address: 0x%lx\n",
- current->comm, current->pid, ip);
+ pr_warn_ratelimited("#AC: %s/%d (%s) took a split_lock trap at address: 0x%lx\n",
+ current->comm, current->pid,
+ is_guest ? "guest" : "user", ip);
current->reported_split_lock = 1;
if (sysctl_sld_mitigate) {
@@ -1194,11 +1195,11 @@ static void split_lock_warn(unsigned long ip)
bool handle_guest_split_lock(unsigned long ip)
{
if (sld_state == sld_warn) {
- split_lock_warn(ip);
+ split_lock_warn(ip, true);
return true;
}
- pr_warn_once("#AC: %s/%d %s split_lock trap at address: 0x%lx\n",
+ pr_warn_once("#AC: %s/%d %s (guest) split_lock trap at address: 0x%lx\n",
current->comm, current->pid,
sld_state == sld_fatal ? "fatal" : "bogus", ip);
@@ -1237,7 +1238,7 @@ bool handle_user_split_lock(struct pt_regs *regs, long error_code)
{
if ((regs->flags & X86_EFLAGS_AC) || sld_state == sld_fatal)
return false;
- split_lock_warn(regs->ip);
+ split_lock_warn(regs->ip, false);
return true;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH 1/1] x86/split_lock: add the source of exception to warning logs
2024-02-23 9:47 [PATCH 1/1] x86/split_lock: add the source of exception to warning logs Dongli Zhang
@ 2024-02-23 16:27 ` Dave Hansen
2024-02-24 3:19 ` Dongli Zhang
0 siblings, 1 reply; 3+ messages in thread
From: Dave Hansen @ 2024-02-23 16:27 UTC (permalink / raw)
To: Dongli Zhang, x86
Cc: tglx, mingo, bp, dave.hansen, hpa, linux-kernel, joe.jin
On 2/23/24 01:47, Dongli Zhang wrote:
> @@ -1194,11 +1195,11 @@ static void split_lock_warn(unsigned long ip)
> bool handle_guest_split_lock(unsigned long ip)
> {
> if (sld_state == sld_warn) {
> - split_lock_warn(ip);
> + split_lock_warn(ip, true);
> return true;
> }
I really despise random true/falses getting passed to functions.
Wouldn't this be a lot easier to read if you just passed the string in:
split_lock_warn(ip, "guest");
rather than bools plus the ternary form dance?
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH 1/1] x86/split_lock: add the source of exception to warning logs
2024-02-23 16:27 ` Dave Hansen
@ 2024-02-24 3:19 ` Dongli Zhang
0 siblings, 0 replies; 3+ messages in thread
From: Dongli Zhang @ 2024-02-24 3:19 UTC (permalink / raw)
To: Dave Hansen, x86; +Cc: tglx, mingo, bp, dave.hansen, hpa, linux-kernel, joe.jin
Hi Dave,
On 2/23/24 08:27, Dave Hansen wrote:
> On 2/23/24 01:47, Dongli Zhang wrote:
>> @@ -1194,11 +1195,11 @@ static void split_lock_warn(unsigned long ip)
>> bool handle_guest_split_lock(unsigned long ip)
>> {
>> if (sld_state == sld_warn) {
>> - split_lock_warn(ip);
>> + split_lock_warn(ip, true);
>> return true;
>> }
>
> I really despise random true/falses getting passed to functions.
>
> Wouldn't this be a lot easier to read if you just passed the string in:
>
> split_lock_warn(ip, "guest");
>
> rather than bools plus the ternary form dance?
Thank you very much!
I will send v2 after waiting if there is no further comment.
Dongli Zhang
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-24 3:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-23 9:47 [PATCH 1/1] x86/split_lock: add the source of exception to warning logs Dongli Zhang
2024-02-23 16:27 ` Dave Hansen
2024-02-24 3:19 ` Dongli Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox