[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4] i386: Add ratelimit for bus locks acquired in guest
From: |
Eduardo Habkost |
Subject: |
Re: [PATCH v4] i386: Add ratelimit for bus locks acquired in guest |
Date: |
Tue, 1 Jun 2021 14:18:37 -0400 |
On Mon, May 31, 2021 at 01:14:54PM +0800, Chenyi Qiang wrote:
>
>
> On 5/28/2021 5:19 AM, Eduardo Habkost wrote:
> > On Fri, May 21, 2021 at 12:38:20PM +0800, Chenyi Qiang wrote:
> > [...]
> > > @@ -4222,6 +4247,15 @@ void kvm_arch_pre_run(CPUState *cpu, struct
> > > kvm_run *run)
> > > }
> > > }
> > > +static void kvm_rate_limit_on_bus_lock(void)
> > > +{
> > > + uint64_t delay_ns =
> > > ratelimit_calculate_delay(&bus_lock_ratelimit_ctrl, 1);
> > > +
> > > + if (delay_ns) {
> > > + g_usleep(delay_ns / SCALE_US);
> > > + }
> > > +}
> > > +
> > > MemTxAttrs kvm_arch_post_run(CPUState *cpu, struct kvm_run *run)
> > > {
> > > X86CPU *x86_cpu = X86_CPU(cpu);
> > > @@ -4237,6 +4271,9 @@ MemTxAttrs kvm_arch_post_run(CPUState *cpu, struct
> > > kvm_run *run)
> > > } else {
> > > env->eflags &= ~IF_MASK;
> > > }
> > > + if (run->flags & KVM_RUN_X86_BUS_LOCK) {
> >
> > Does the KVM API guarantee that KVM_RUN_X86_BUS_LOCK will never
> > be set if KVM_BUS_LOCK_DETECTION_EXIT isn't enabled? (Otherwise
> > we risk crashing in ratelimit_calculate_delay() above if rate
> > limiting is disabled).
> >
>
> Yes. KVM_RUN_X86_BUS_LOCK flag is set when bus lock VM exit happens. Bus
> lock VM exit is disabled by default and can only be enabled through the
> KVM_BUS_LOCK_DETECTION_EXIT capability.
I'm queueing on x86-next, thanks!
--
Eduardo
- Re: [PATCH v4] i386: Add ratelimit for bus locks acquired in guest,
Eduardo Habkost <=