From patchwork Fri May 17 13:03:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 10947963 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3C4D013AD for ; Fri, 17 May 2019 13:03:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A60A27C2D for ; Fri, 17 May 2019 13:03:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EA0427EE2; Fri, 17 May 2019 13:03:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC20727C2D for ; Fri, 17 May 2019 13:03:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728771AbfEQNDL (ORCPT ); Fri, 17 May 2019 09:03:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47204 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728746AbfEQNDK (ORCPT ); Fri, 17 May 2019 09:03:10 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A6344C09AD1A; Fri, 17 May 2019 13:03:10 +0000 (UTC) Received: from thinkpad.redhat.com (unknown [10.40.205.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 96838600C4; Fri, 17 May 2019 13:03:08 +0000 (UTC) From: Laurent Vivier To: =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , Paolo Bonzini , kvm@vger.kernel.org Cc: kvm-ppc@vger.kernel.org, Thomas Huth , Suraj Jitindar Singh , Laurent Vivier Subject: [kvm-unit-tests PULL 1/2] powerpc: Allow for a custom decr value to be specified to load on decr excp Date: Fri, 17 May 2019 15:03:04 +0200 Message-Id: <20190517130305.32123-2-lvivier@redhat.com> In-Reply-To: <20190517130305.32123-1-lvivier@redhat.com> References: <20190517130305.32123-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 17 May 2019 13:03:10 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Suraj Jitindar Singh Currently the handler for a decrementer exception will simply reload the maximum value (0x7FFFFFFF), which will take ~4 seconds to expire again. This means that if a vcpu cedes, it will be ~4 seconds between wakeups. The h_cede_tm test is testing a known breakage when a guest cedes while suspended. To be sure we cede 500 times to check for the bug. However since it takes ~4 seconds to be woken up once we've ceded, we only get through ~20 iterations before we reach the 90 seconds timeout and the test appears to fail. Add an option when registering the decrementer handler to specify the value which should be reloaded by the handler, allowing the timeout to be chosen. Modify the spr test to use the max timeout to preserve existing behaviour. Modify the h_cede_tm test to use a 10ms timeout to ensure we can perform 500 iterations before hitting the 90 second time limit for a test. This means the h_cede_tm test now succeeds rather than timing out. Signed-off-by: Suraj Jitindar Singh Reviewed-by: Thomas Huth Reviewed-by: Laurent Vivier [lv: reset initial value to 0x3FFFFFFF] Signed-off-by: Laurent Vivier --- lib/powerpc/handlers.c | 7 ++++--- powerpc/sprs.c | 3 ++- powerpc/tm.c | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/powerpc/handlers.c b/lib/powerpc/handlers.c index be8226a2e573..c8721e0a11ae 100644 --- a/lib/powerpc/handlers.c +++ b/lib/powerpc/handlers.c @@ -12,11 +12,12 @@ /* * Generic handler for decrementer exceptions (0x900) - * Just reset the decrementer back to its maximum value (0x7FFFFFFF) + * Just reset the decrementer back to the value specified when registering the + * handler */ -void dec_except_handler(struct pt_regs *regs __unused, void *data __unused) +void dec_except_handler(struct pt_regs *regs __unused, void *data) { - uint32_t dec = 0x7FFFFFFF; + uint64_t dec = *((uint64_t *) data); asm volatile ("mtdec %0" : : "r" (dec)); } diff --git a/powerpc/sprs.c b/powerpc/sprs.c index 6744bd8d8049..3c2d98c9ca99 100644 --- a/powerpc/sprs.c +++ b/powerpc/sprs.c @@ -253,6 +253,7 @@ int main(int argc, char **argv) 0x1234567890ABCDEFULL, 0xFEDCBA0987654321ULL, -1ULL, }; + static uint64_t decr = 0x7FFFFFFF; /* Max value */ for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-w")) { @@ -288,7 +289,7 @@ int main(int argc, char **argv) (void) getchar(); } else { puts("Sleeping...\n"); - handle_exception(0x900, &dec_except_handler, NULL); + handle_exception(0x900, &dec_except_handler, &decr); asm volatile ("mtdec %0" : : "r" (0x3FFFFFFF)); hcall(H_CEDE); } diff --git a/powerpc/tm.c b/powerpc/tm.c index bd56baa5b3d8..c588985352f4 100644 --- a/powerpc/tm.c +++ b/powerpc/tm.c @@ -95,11 +95,13 @@ static bool enable_tm(void) static void test_h_cede_tm(int argc, char **argv) { int i; + static uint64_t decr = 0x3FFFFF; /* ~10ms */ if (argc > 2) report_abort("Unsupported argument: '%s'", argv[2]); - handle_exception(0x900, &dec_except_handler, NULL); + handle_exception(0x900, &dec_except_handler, &decr); + asm volatile ("mtdec %0" : : "r" (decr)); if (!start_all_cpus(halt, 0)) report_abort("Failed to start secondary cpus"); From patchwork Fri May 17 13:03:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 10947965 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EF4B613AD for ; Fri, 17 May 2019 13:03:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE6D3268AE for ; Fri, 17 May 2019 13:03:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2B7327E5A; Fri, 17 May 2019 13:03:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E27BB268AE for ; Fri, 17 May 2019 13:03:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728820AbfEQNDN (ORCPT ); Fri, 17 May 2019 09:03:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60298 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728746AbfEQNDN (ORCPT ); Fri, 17 May 2019 09:03:13 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 251F830642AA; Fri, 17 May 2019 13:03:13 +0000 (UTC) Received: from thinkpad.redhat.com (unknown [10.40.205.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16050600C4; Fri, 17 May 2019 13:03:10 +0000 (UTC) From: Laurent Vivier To: =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , Paolo Bonzini , kvm@vger.kernel.org Cc: kvm-ppc@vger.kernel.org, Thomas Huth , Suraj Jitindar Singh , Laurent Vivier Subject: [kvm-unit-tests PULL 2/2] powerpc: Make h_cede_tm test run by default Date: Fri, 17 May 2019 15:03:05 +0200 Message-Id: <20190517130305.32123-3-lvivier@redhat.com> In-Reply-To: <20190517130305.32123-1-lvivier@redhat.com> References: <20190517130305.32123-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 17 May 2019 13:03:13 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Suraj Jitindar Singh This test was initially designed to test for a known bug where performing a sequence of H_CEDE hcalls while suspended would cause a vcpu to lockup in the host. The fix has been available for some time now, so to increase coverage of this test remove the no-default flag. Signed-off-by: Suraj Jitindar Singh Reviewed-by: Laurent Vivier Acked-by: Thomas Huth Signed-off-by: Laurent Vivier --- powerpc/unittests.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerpc/unittests.cfg b/powerpc/unittests.cfg index af535b7f8982..1e7494801273 100644 --- a/powerpc/unittests.cfg +++ b/powerpc/unittests.cfg @@ -64,7 +64,7 @@ file = emulator.elf file = tm.elf smp = 2,threads=2 extra_params = -machine cap-htm=on -append "h_cede_tm" -groups = nodefault,h_cede_tm +groups = h_cede_tm [sprs] file = sprs.elf