From patchwork Thu Dec 8 17:05:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 13068640 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 428B5C001B2 for ; Thu, 8 Dec 2022 17:06:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbiLHRG2 (ORCPT ); Thu, 8 Dec 2022 12:06:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229685AbiLHRG1 (ORCPT ); Thu, 8 Dec 2022 12:06:27 -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 DC68085D00 for ; Thu, 8 Dec 2022 09:05:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670519127; 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=asW2vy461e0rSdotWn0NTs/7xLf9pA0Y4lAnlw3dKwM=; b=LBaNMV4HsBCCZx0KqKyQEV06co1wHrvUrkFh8WxX/fP8NiV37jYLI5RQoKy3/J6/rt+1Kq xZRYi+u8jNPcDrzzmPWindSUdh7U3LcFTExuQc1ut5ax6o2cufnsPlLQbl2/PHiizwEraI 73li8aYbrJ+MyA2hETDPxyxVwB7EB3M= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-650-Iy2TNGiSPjS-tC2gbk2xew-1; Thu, 08 Dec 2022 12:05:08 -0500 X-MC-Unique: Iy2TNGiSPjS-tC2gbk2xew-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0097A3817963; Thu, 8 Dec 2022 17:05:08 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.125]) by smtp.corp.redhat.com (Postfix) with ESMTP id A23AC40C206B; Thu, 8 Dec 2022 17:05:06 +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 v2 PATCH] s390x: sie: Test whether the epoch extension field is working as expected Date: Thu, 8 Dec 2022 18:05:02 +0100 Message-Id: <20221208170502.17984-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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 determine whether the host kernel of a machine has already been fixed or not. Signed-off-by: Thomas Huth Reviewed-by: Claudio Imbrenda --- v2: Remove the spurious "2" from the diag 44 opcode s390x/sie.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/s390x/sie.c b/s390x/sie.c index 87575b29..cd3cea10 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 */ + 0x83000044 /* 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: