From patchwork Wed Dec 7 13:31:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 13067145 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52C6EC352A1 for ; Wed, 7 Dec 2022 13:32:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229975AbiLGNcZ (ORCPT ); Wed, 7 Dec 2022 08:32:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229863AbiLGNcX (ORCPT ); Wed, 7 Dec 2022 08:32:23 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27FFC59866 for ; Wed, 7 Dec 2022 05:31:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670419888; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Oq9C4AbUhIi1FkopfApdzR8zStuiPjWtMWGLibu/XSk=; b=YphZRc/OaYKKc9CYsCTG9DHtC1YX+TfBoKw9xikOMG1k90uEdLoo70H78EYx643N9p8YE9 bZb3rd21E5MIxnfsMvG8XHL0+fzHk9EGZAGGgJfEqDeYUJz1tK3113Y+cRuKuOq8VS298B wq+psFww5yHUfpuvpvqPuiwF+1IjX/o= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-154-rdcAVbOONcGXPhXnplAQzw-1; Wed, 07 Dec 2022 08:31:25 -0500 X-MC-Unique: rdcAVbOONcGXPhXnplAQzw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D313685A5A6; Wed, 7 Dec 2022 13:31:24 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D39F9E70; Wed, 7 Dec 2022 13:31:23 +0000 (UTC) From: Thomas Huth To: kvm@vger.kernel.org, Janosch Frank , Claudio Imbrenda Cc: linux-s390@vger.kernel.org, David Hildenbrand Subject: [kvm-unit-tests PATCH] s390x: sie: Test whether the epoch extension field is working as expected Date: Wed, 7 Dec 2022 14:31:18 +0100 Message-Id: <20221207133118.70746-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org We recently discovered a bug with the time management in nested scenarios which got fixed by kernel commit "KVM: s390: vsie: Fix the initialization of the epoch extension (epdx) field". This adds a simple test for this bug so that it is easier to decide whether the host kernel of a machine has already been fixed or not. Signed-off-by: Thomas Huth --- s390x/sie.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/s390x/sie.c b/s390x/sie.c index 87575b29..7ec4b030 100644 --- a/s390x/sie.c +++ b/s390x/sie.c @@ -58,6 +58,33 @@ static void test_diags(void) } } +static void test_epoch_ext(void) +{ + u32 instr[] = { + 0xb2780000, /* STCKE 0 */ + 0x83020044 /* DIAG 0x44 to intercept */ + }; + + if (!test_facility(139)) { + report_skip("epdx: Multiple Epoch Facility is not available"); + return; + } + + guest[0] = 0x00; + memcpy(guest_instr, instr, sizeof(instr)); + + vm.sblk->gpsw.addr = PAGE_SIZE * 2; + vm.sblk->gpsw.mask = PSW_MASK_64; + + vm.sblk->ecd |= ECD_MEF; + vm.sblk->epdx = 0x47; /* Setting the epoch extension here ... */ + + sie(&vm); + + /* ... should result in the same epoch extension here: */ + report(guest[0] == 0x47, "epdx: different epoch is visible in the guest"); +} + static void setup_guest(void) { setup_vm(); @@ -80,6 +107,7 @@ int main(void) setup_guest(); test_diags(); + test_epoch_ext(); sie_guest_destroy(&vm); done: