From patchwork Mon May 29 11:06:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 9753085 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7C4DE602B1 for ; Mon, 29 May 2017 11:06:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6457925EA6 for ; Mon, 29 May 2017 11:06:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 590A92623C; Mon, 29 May 2017 11:06:42 +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=-6.9 required=2.0 tests=BAYES_00,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 AE12425EA6 for ; Mon, 29 May 2017 11:06:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750903AbdE2LGj (ORCPT ); Mon, 29 May 2017 07:06:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56182 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750871AbdE2LGi (ORCPT ); Mon, 29 May 2017 07:06:38 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4A7EE80B52; Mon, 29 May 2017 11:06:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4A7EE80B52 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=david@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4A7EE80B52 Received: from t460s.redhat.com (ovpn-117-161.ams2.redhat.com [10.36.117.161]) by smtp.corp.redhat.com (Postfix) with ESMTP id 083271879E; Mon, 29 May 2017 11:06:31 +0000 (UTC) From: David Hildenbrand To: kvm@vger.kernel.org Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Thomas Huth , david@redhat.com, Christian Borntraeger Subject: [kvm-unit-tests PATCH v1] s390x: generate asm offsets for the lowcore Date: Mon, 29 May 2017 13:06:31 +0200 Message-Id: <20170529110631.23071-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 29 May 2017 11:06:38 +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 Add the s390x psw and lowcore structs and generate asm offsets for lowcore fields. Add all lowcore fields defined in the current PoP (z13). Signed-off-by: David Hildenbrand Reviewed-by: Thomas Huth --- lib/s390x/asm-offsets.c | 70 +++++++++++++++++++++++++++++++++++++ lib/s390x/asm/arch_def.h | 85 +++++++++++++++++++++++++++++++++++++++++++++ lib/s390x/asm/asm-offsets.h | 10 ++++++ s390x/Makefile | 8 ++++- 4 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 lib/s390x/asm-offsets.c create mode 100644 lib/s390x/asm/arch_def.h create mode 100644 lib/s390x/asm/asm-offsets.h diff --git a/lib/s390x/asm-offsets.c b/lib/s390x/asm-offsets.c new file mode 100644 index 0000000..28915e5 --- /dev/null +++ b/lib/s390x/asm-offsets.c @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2017 Red Hat Inc + * + * Authors: + * David Hildenbrand + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License version 2. + */ +#include +#include +#include + +int main(void) +{ + OFFSET(GEN_LC_EXT_INT_PARAM, lowcore, ext_int_param); + OFFSET(GEN_LC_CPU_ADDR, lowcore, cpu_addr); + OFFSET(GEN_LC_EXT_INT_CODE, lowcore, ext_int_code); + OFFSET(GEN_LC_SVC_INT_ID, lowcore, svc_int_id); + OFFSET(GEN_LC_SVC_INT_CODE, lowcore, svc_int_code); + OFFSET(GEN_LC_PGM_INT_ID, lowcore, pgm_int_id); + OFFSET(GEN_LC_PGM_INT_CODE, lowcore, pgm_int_code); + OFFSET(GEN_LC_DXC_VXC, lowcore, dxc_vxc); + OFFSET(GEN_LC_MON_CLASS_NB, lowcore, mon_class_nb); + OFFSET(GEN_LC_PER_CODE, lowcore, per_code); + OFFSET(GEN_LC_PER_ATMID, lowcore, per_atmid); + OFFSET(GEN_LC_PER_ADDR, lowcore, per_addr); + OFFSET(GEN_LC_EXC_ACC_ID, lowcore, exc_acc_id); + OFFSET(GEN_LC_PER_ACC_ID, lowcore, per_acc_id); + OFFSET(GEN_LC_OP_ACC_ID, lowcore, op_acc_id); + OFFSET(GEN_LC_ARCH_MODE_ID, lowcore, arch_mode_id); + OFFSET(GEN_LC_TRANS_EXC_ID, lowcore, trans_exc_id); + OFFSET(GEN_LC_MON_CODE, lowcore, mon_code); + OFFSET(GEN_LC_SUBSYS_ID_WORD, lowcore, subsys_id_word); + OFFSET(GEN_LC_IO_INT_PARAM, lowcore, io_int_param); + OFFSET(GEN_LC_IO_INT_WORD, lowcore, io_int_word); + OFFSET(GEN_LC_STFL, lowcore, stfl); + OFFSET(GEN_LC_MCCK_INT_CODE, lowcore, mcck_int_code); + OFFSET(GEN_LC_EXT_DAMAGE_CODE, lowcore, ext_damage_code); + OFFSET(GEN_LC_FAILING_STORAGE_ADDR, lowcore, failing_storage_addr); + OFFSET(GEN_LC_EMON_CA_ORIGIN, lowcore, emon_ca_origin); + OFFSET(GEN_LC_EMON_CA_SIZE, lowcore, emon_ca_size); + OFFSET(GEN_LC_EMON_EXC_COUNT, lowcore, emon_exc_count); + OFFSET(GEN_LC_BREAKING_EVENT_ADDR, lowcore, breaking_event_addr); + OFFSET(GEN_LC_RESTART_OLD_PSW, lowcore, restart_old_psw); + OFFSET(GEN_LC_EXT_OLD_PSW, lowcore, ext_old_psw); + OFFSET(GEN_LC_SVC_OLD_PSW, lowcore, svc_old_psw); + OFFSET(GEN_LC_PGM_OLD_PSW, lowcore, pgm_old_psw); + OFFSET(GEN_LC_MCCK_OLD_PSW, lowcore, mcck_old_psw); + OFFSET(GEN_LC_IO_OLD_PSW, lowcore, io_old_psw); + OFFSET(GEN_LC_RESTART_NEW_PSW, lowcore, restart_new_psw); + OFFSET(GEN_LC_EXT_NEW_PSW, lowcore, ext_new_psw); + OFFSET(GEN_LC_SVC_NEW_PSW, lowcore, svc_new_psw); + OFFSET(GEN_LC_PGM_NEW_PSW, lowcore, pgm_new_psw); + OFFSET(GEN_LC_MCCK_NEW_PSW, lowcore, mcck_new_psw); + OFFSET(GEN_LC_IO_NEW_PSW, lowcore, io_new_psw); + OFFSET(GEN_LC_FPRS_SA, lowcore, fprs_sa); + OFFSET(GEN_LC_GRS_SA, lowcore, grs_sa); + OFFSET(GEN_LC_PSW_SA, lowcore, psw_sa); + OFFSET(GEN_LC_PREFIX_SA, lowcore, prefix_sa); + OFFSET(GEN_LC_FPC_SA, lowcore, fpc_sa); + OFFSET(GEN_LC_TOD_PR_SA, lowcore, tod_pr_sa); + OFFSET(GEN_LC_CPUTM_SA, lowcore, cputm_sa); + OFFSET(GEN_LC_CC_SA, lowcore, cc_sa); + OFFSET(GEN_LC_ARS_SA, lowcore, ars_sa); + OFFSET(GEN_LC_CRS_SA, lowcore, crs_sa); + OFFSET(GEN_LC_PGM_INT_TDB, lowcore, pgm_int_tdb); + + return 0; +} diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h new file mode 100644 index 0000000..25c9516 --- /dev/null +++ b/lib/s390x/asm/arch_def.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2017 Red Hat Inc + * + * Authors: + * David Hildenbrand + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License version 2. + */ +#ifndef _ASM_S390X_ARCH_DEF_H_ +#define _ASM_S390X_ARCH_DEF_H_ + +struct psw { + uint64_t mask; + uint64_t addr; +} __attribute__ ((__packed__)); + +struct lowcore { + uint8_t pad_0x0000[0x0080 - 0x0000]; /* 0x0000 */ + uint32_t ext_int_param; /* 0x0080 */ + uint16_t cpu_addr; /* 0x0084 */ + uint16_t ext_int_code; /* 0x0086 */ + uint16_t svc_int_id; /* 0x0088 */ + uint16_t svc_int_code; /* 0x008a */ + uint16_t pgm_int_id; /* 0x008c */ + uint16_t pgm_int_code; /* 0x008e */ + uint32_t dxc_vxc; /* 0x0090 */ + uint16_t mon_class_nb; /* 0x0094 */ + uint8_t per_code; /* 0x0096 */ + uint8_t per_atmid; /* 0x0097 */ + uint64_t per_addr; /* 0x0098 */ + uint8_t exc_acc_id; /* 0x00a0 */ + uint8_t per_acc_id; /* 0x00a1 */ + uint8_t op_acc_id; /* 0x00a2 */ + uint8_t arch_mode_id; /* 0x00a3 */ + uint8_t pad_0x00a4[0x00a8 - 0x00a4]; /* 0x00a4 */ + uint64_t trans_exc_id; /* 0x00a8 */ + uint64_t mon_code; /* 0x00b0 */ + uint32_t subsys_id_word; /* 0x00b8 */ + uint32_t io_int_param; /* 0x00bc */ + uint32_t io_int_word; /* 0x00c0 */ + uint8_t pad_0x00c4[0x00c8 - 0x00c4]; /* 0x00c4 */ + uint32_t stfl; /* 0x00c8 */ + uint8_t pad_0x00cc[0x00e8 - 0x00cc]; /* 0x00cc */ + uint64_t mcck_int_code; /* 0x00e8 */ + uint8_t pad_0x00f0[0x00f4 - 0x00f0]; /* 0x00f0 */ + uint32_t ext_damage_code; /* 0x00f4 */ + uint64_t failing_storage_addr; /* 0x00f8 */ + uint64_t emon_ca_origin; /* 0x0100 */ + uint32_t emon_ca_size; /* 0x0108 */ + uint32_t emon_exc_count; /* 0x010c */ + uint64_t breaking_event_addr; /* 0x0110 */ + uint8_t pad_0x0118[0x0120 - 0x0118]; /* 0x0118 */ + struct psw restart_old_psw; /* 0x0120 */ + struct psw ext_old_psw; /* 0x0130 */ + struct psw svc_old_psw; /* 0x0140 */ + struct psw pgm_old_psw; /* 0x0150 */ + struct psw mcck_old_psw; /* 0x0160 */ + struct psw io_old_psw; /* 0x0170 */ + uint8_t pad_0x0180[0x01a0 - 0x0180]; /* 0x0180 */ + struct psw restart_new_psw; /* 0x01a0 */ + struct psw ext_new_psw; /* 0x01b0 */ + struct psw svc_new_psw; /* 0x01c0 */ + struct psw pgm_new_psw; /* 0x01d0 */ + struct psw mcck_new_psw; /* 0x01e0 */ + struct psw io_new_psw; /* 0x01f0 */ + uint8_t pad_0x0200[0x1200 - 0x0200]; /* 0x0200 */ + uint64_t fprs_sa[16]; /* 0x1200 */ + uint64_t grs_sa[16]; /* 0x1280 */ + struct psw psw_sa; /* 0x1300 */ + uint8_t pad_0x1310[0x1318 - 0x1310]; /* 0x1310 */ + uint32_t prefix_sa; /* 0x1318 */ + uint32_t fpc_sa; /* 0x131c */ + uint8_t pad_0x1320[0x1324 - 0x1320]; /* 0x1320 */ + uint32_t tod_pr_sa; /* 0x1324 */ + uint64_t cputm_sa; /* 0x1328 */ + uint64_t cc_sa; /* 0x1330 */ + uint8_t pad_0x1338[0x1340 - 0x1338]; /* 0x1338 */ + uint32_t ars_sa[16]; /* 0x1340 */ + uint64_t crs_sa[16]; /* 0x1380 */ + uint8_t pad_0x1400[0x1800 - 0x1400]; /* 0x1400 */ + uint8_t pgm_int_tdb[0x1900 - 0x1800]; /* 0x1800 */ +} __attribute__ ((__packed__)); + +#endif diff --git a/lib/s390x/asm/asm-offsets.h b/lib/s390x/asm/asm-offsets.h new file mode 100644 index 0000000..a6d7af8 --- /dev/null +++ b/lib/s390x/asm/asm-offsets.h @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2017 Red Hat Inc + * + * Authors: + * David Hildenbrand + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License version 2. + */ +#include diff --git a/s390x/Makefile b/s390x/Makefile index e80add0..4e4b94a 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -15,6 +15,9 @@ LDFLAGS += -nostdlib # We want to keep intermediate files .PRECIOUS: %.o +asm-offsets = lib/$(ARCH)/asm-offsets.h +include $(SRCDIR)/scripts/asm-offsets.mak + cflatobjs += lib/util.o cflatobjs += lib/alloc.o cflatobjs += lib/s390x/io.o @@ -33,5 +36,8 @@ FLATLIBS = $(libcflat) $(filter %.o, $^) $(FLATLIBS) $(@:.elf=.aux.o) $(RM) $(@:.elf=.aux.o) -arch_clean: +arch_clean: asm_offsets_clean $(RM) $(TEST_DIR)/*.{o,elf} $(TEST_DIR)/.*.d lib/s390x/.*.d + +generated-files = $(asm-offsets) +$(test_cases:.elf=.o) $(cstart.o) $(cflatobjs): $(generated-files)