From: Sean Christopherson <seanjc@google.com>
To: Michal Luczaj <mhal@rbox.co>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com
Subject: Re: [kvm-unit-tests PATCH] x86/emulator: Test POP-SS blocking
Date: Mon, 22 Aug 2022 15:42:34 +0000 [thread overview]
Message-ID: <YwOj6tzvIoG34/sF@google.com> (raw)
In-Reply-To: <9b853239-a3df-f124-e793-44cbadfbbd8f@rbox.co>
On Mon, Aug 22, 2022, Michal Luczaj wrote:
> On 8/22/22 00:06, Michal Luczaj wrote:
> > Note that doing this the ASM_TRY() way would require extending
> > setup_idt() (to handle #DB) and introducing another ASM_TRY() variant
> > (one without the initial `movl $0, %%gs:4`).
>
> Replying to self as I was wrong regarding the need for another ASM_TRY() variant.
> Once setup_idt() is told to handle #DB,
Hmm, it might be a moot point for this patch (see below), but my vote is to have
setup_idt() wire up all known handlers to check_exception_table(). I don't see
any reason to skip some vectors. Code with __ASM_TRY() will explode no matter what,
so it's not like it risks suppressing completely unexpected faults.
for (i = 0; i < 32; i++) {
if (!idt_handlers[i])
continue;
set_idt_entry(i, idt_handlers[i], 0);
handle_exception(i, check_exception_table);
}
> test can be simplified to something like
>
> asm volatile("push %[ss]\n\t"
> __ASM_TRY(KVM_FEP "pop %%ss", "1f")
> "ex_blocked: mov $1, %[success]\n\t"
So I'm 99% certain this only passes because KVM doesn't emulate the `mov $1, %[success]`.
kvm_vcpu_check_code_breakpoint() honors EFLAGS.RF, but not MOV/POP_SS blocking.
I.e. I would expect this to fail if the `mov` were also tagged KVM_FEP.
Single-step and data #DBs appear to be broken as well, I don't see anything that
will suppress them for MOV/POP_SS. Of course, KVM doesn't emulate data #DBs at
all, so testing that case is probably not worthwhile at this time.
The reason I say the setup_idt() change is a moot point is because I think it
would be better to put this testcase into debug.c (where "this" testcase is really
going to be multiple testcases). With macro shenanigans (or code patching), it
should be fairly easy to run all testcases with both FEP=0 and FEP=1.
Then it's "just" a matter of adding a code #DB testcase. __run_single_step_db_test()
and run_ss_db_test() aren't fundamentally tied to single-step, i.e. can simply be
renamed. For simplicity, I'd say just skip the usermode test for code #DBs, IMO
it's not worth the extra coverage.
next prev parent reply other threads:[~2022-08-22 15:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-21 21:59 [PATCH] KVM: x86/emulator: Fix handing of POP SS to correctly set interruptibility Michal Luczaj
2022-08-21 22:06 ` [kvm-unit-tests PATCH] x86/emulator: Test POP-SS blocking Michal Luczaj
2022-08-22 2:40 ` Michal Luczaj
2022-08-22 15:42 ` Sean Christopherson [this message]
2022-08-22 18:30 ` Nadav Amit
2022-08-22 18:37 ` Sean Christopherson
2022-08-23 0:16 ` Michal Luczaj
2022-08-24 18:32 ` Sean Christopherson
2022-08-24 21:49 ` Michal Luczaj
2022-08-25 17:03 ` Sean Christopherson
2022-08-25 17:32 ` Michal Luczaj
2022-08-25 17:56 ` Sean Christopherson
2022-08-24 0:20 ` [PATCH] KVM: x86/emulator: Fix handing of POP SS to correctly set interruptibility Sean Christopherson
2022-08-24 17:19 ` Paolo Bonzini
2022-08-30 21:41 ` Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YwOj6tzvIoG34/sF@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=mhal@rbox.co \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox