From: Janosch Frank <frankja@linux.ibm.com>
To: Thomas Huth <thuth@redhat.com>, kvm@vger.kernel.org
Cc: borntraeger@de.ibm.com, david@redhat.com, cohuck@redhat.com,
linux-s390@vger.kernel.org
Subject: Re: [PATCH v8 4/4] selftests: KVM: testing the local IRQs resets
Date: Thu, 30 Jan 2020 12:33:00 +0100 [thread overview]
Message-ID: <cf61103b-86b0-5bc2-51a2-46ff6485c632@linux.ibm.com> (raw)
In-Reply-To: <a9fd8939-503e-bf11-7f5e-bb83a79a1bf9@redhat.com>
[-- Attachment #1.1: Type: text/plain, Size: 3331 bytes --]
On 1/30/20 12:10 PM, Thomas Huth wrote:
> On 29/01/2020 21.03, Janosch Frank wrote:
>> From: Pierre Morel <pmorel@linux.ibm.com>
>>
>> Local IRQs are reset by a normal cpu reset. The initial cpu reset and
>> the clear cpu reset, as superset of the normal reset, both clear the
>> IRQs too.
>>
>> Let's inject an interrupt to a vCPU before calling a reset and see if
>> it is gone after the reset.
>>
>> We choose to inject only an emergency interrupt at this point and can
>> extend the test to other types of IRQs later.
>>
>> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
>> ---
>> tools/testing/selftests/kvm/s390x/resets.c | 57 ++++++++++++++++++++++
>> 1 file changed, 57 insertions(+)
>>
>> diff --git a/tools/testing/selftests/kvm/s390x/resets.c b/tools/testing/selftests/kvm/s390x/resets.c
>> index 2b2378cc9e80..299c1686f98c 100644
>> --- a/tools/testing/selftests/kvm/s390x/resets.c
>> +++ b/tools/testing/selftests/kvm/s390x/resets.c
>> @@ -14,6 +14,9 @@
>> #include "kvm_util.h"
>>
>> #define VCPU_ID 3
>> +#define LOCAL_IRQS 32
>> +
>> +struct kvm_s390_irq buf[VCPU_ID + LOCAL_IRQS];
>>
>> struct kvm_vm *vm;
>> struct kvm_run *run;
>> @@ -52,6 +55,29 @@ static void test_one_reg(uint64_t id, uint64_t value)
>> TEST_ASSERT(eval_reg == value, "value == %s", value);
>> }
>>
>> +static void assert_noirq(void)
>> +{
>> + struct kvm_s390_irq_state irq_state;
>> + int irqs;
>> +
>> + if (!(kvm_check_cap(KVM_CAP_S390_INJECT_IRQ) &&
>> + kvm_check_cap(KVM_CAP_S390_IRQ_STATE)))
>> + return;
>> +
>> + irq_state.len = sizeof(buf);
>> + irq_state.buf = (unsigned long)buf;
>> + irqs = _vcpu_ioctl(vm, VCPU_ID, KVM_S390_GET_IRQ_STATE, &irq_state);
>> + /*
>> + * irqs contains the number of retrieved interrupts, apart from the
>> + * emergency call that should be cleared by the resets, there should be
>> + * none.
>> + */
>> + if (irqs < 0)
>> + printf("Error by getting IRQ: errno %d\n", errno);
>> +
>> + TEST_ASSERT(!irqs, "IRQ pending");
>> +}
>> +
>> static void assert_clear(void)
>> {
>> struct kvm_sregs sregs;
>> @@ -93,6 +119,31 @@ static void assert_initial(void)
>> static void assert_normal(void)
>> {
>> test_one_reg(KVM_REG_S390_PFTOKEN, KVM_S390_PFAULT_TOKEN_INVALID);
>> + assert_noirq();
>> +}
>> +
>> +static int inject_irq(int cpu_id)
>> +{
>> + struct kvm_s390_irq_state irq_state;
>> + struct kvm_s390_irq *irq = &buf[0];
>> + int irqs;
>> +
>> + if (!(kvm_check_cap(KVM_CAP_S390_INJECT_IRQ) &&
>> + kvm_check_cap(KVM_CAP_S390_IRQ_STATE)))
>> + return 0;
>> +
>> + /* Inject IRQ */
>> + irq_state.len = sizeof(struct kvm_s390_irq);
>> + irq_state.buf = (unsigned long)buf;
>> + irq->type = KVM_S390_INT_EMERGENCY;
>> + irq->u.emerg.code = cpu_id;
>> + irqs = _vcpu_ioctl(vm, cpu_id, KVM_S390_SET_IRQ_STATE, &irq_state);
>> + if (irqs < 0) {
>> + printf("Error by injecting INT_EMERGENCY: errno %d\n", errno);
>> + return errno;
>> + }
>
> Can you turn this into a TEST_ASSERT() instead? Otherwise the printf()
> error might go unnoticed.
I've converted both error checks into asserts (set/get irq) and made the
function void.
>
> Apart from that (and the nits that Cornelia already mentioned), the
> patch looks fine to me.
>
> Thomas
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-01-30 11:33 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-29 20:03 [PATCH v8 0/4] KVM: s390: Add new reset vcpu API Janosch Frank
2020-01-29 20:03 ` [PATCH v8 1/4] " Janosch Frank
2020-01-30 8:55 ` [PATCH/FIXUP FOR STABLE BEFORE THIS SERIES] KVM: s390: do not clobber user space fpc during guest reset Christian Borntraeger
2020-01-30 9:49 ` David Hildenbrand
2020-01-30 10:39 ` Cornelia Huck
2020-01-30 10:56 ` Thomas Huth
2020-01-30 11:07 ` Christian Borntraeger
2020-01-30 11:01 ` Christian Borntraeger
2020-01-30 11:14 ` Christian Borntraeger
2020-01-30 11:20 ` David Hildenbrand
2020-01-30 11:27 ` Christian Borntraeger
2020-01-30 11:42 ` [PATCH v2] KVM: s390: do not clobber user space registers during guest reset/store status Christian Borntraeger
2020-01-30 11:44 ` Christian Borntraeger
2020-01-30 12:01 ` Christian Borntraeger
2020-01-30 12:38 ` David Hildenbrand
2020-01-30 9:00 ` [PATCH v8 1/4] KVM: s390: Add new reset vcpu API Thomas Huth
2020-01-30 9:58 ` Christian Borntraeger
2020-01-29 20:03 ` [PATCH v8 2/4] selftests: KVM: Add fpu and one reg set/get library functions Janosch Frank
2020-01-30 10:36 ` Thomas Huth
2020-01-30 13:55 ` Andrew Jones
2020-01-30 14:10 ` Janosch Frank
2020-01-30 14:30 ` Andrew Jones
2020-01-30 14:58 ` Janosch Frank
2020-01-30 15:04 ` Andrew Jones
2020-01-29 20:03 ` [PATCH v8 3/4] selftests: KVM: s390x: Add reset tests Janosch Frank
2020-01-30 10:51 ` Thomas Huth
2020-01-30 11:32 ` Janosch Frank
2020-01-30 11:36 ` Thomas Huth
2020-01-29 20:03 ` [PATCH v8 4/4] selftests: KVM: testing the local IRQs resets Janosch Frank
2020-01-30 10:55 ` Cornelia Huck
2020-01-30 11:18 ` Janosch Frank
2020-01-30 11:28 ` Cornelia Huck
2020-01-30 11:34 ` Janosch Frank
2020-01-30 11:10 ` Thomas Huth
2020-01-30 11:33 ` Janosch Frank [this message]
2020-01-30 9:10 ` [PATCH] KVM: s390: Cleanup initial cpu reset Janosch Frank
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=cf61103b-86b0-5bc2-51a2-46ff6485c632@linux.ibm.com \
--to=frankja@linux.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=thuth@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;
as well as URLs for NNTP newsgroup(s).