From nobody Wed Nov 5 15:53:25 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1497385806344740.3965711926901; Tue, 13 Jun 2017 13:30:06 -0700 (PDT) Received: from localhost ([::1]:45080 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKsRw-0005hT-TY for importer@patchew.org; Tue, 13 Jun 2017 16:30:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40018) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKsP8-00037J-TK for qemu-devel@nongnu.org; Tue, 13 Jun 2017 16:27:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKsP7-000442-Q8 for qemu-devel@nongnu.org; Tue, 13 Jun 2017 16:27:10 -0400 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:36630) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dKsP7-00043p-Kp for qemu-devel@nongnu.org; Tue, 13 Jun 2017 16:27:09 -0400 Received: by mail-qt0-x241.google.com with SMTP id s33so37659243qtg.3 for ; Tue, 13 Jun 2017 13:27:09 -0700 (PDT) Received: from bigtime.twiddle.net.com (97-113-165-157.tukw.qwest.net. [97.113.165.157]) by smtp.gmail.com with ESMTPSA id j65sm9528787qkf.38.2017.06.13.13.27.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 13:27:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=XfrvRCaDVt0vaUpu/TrPTSsdTK4AyptrJIe236pKe8U=; b=MPpwcYOiWEy45YQXK+/wO8XJ1zOEtRpkPo4AnSIKi06545fIytAKPhKKZ/2f3gQWbO oVTdmOm6JHfeAOZqz9C9ctMTKDRpZDgKGEjdx09vaxzpslUkEHuGYFUTRJERH9fRBQ8w DX8+ysIGWR6rjVI1/32KPt7Dec96+YEE2fiBMRHPYWaCjGyGIOppXpD2Z5k9evbLmrKR gWyCpnuj1pYHhFQnPmG8WXQYHe9ov/+LaIMycxdvpYuvcKB6hbIqsWHAaaT0x3nLVQtN vHbsvnOojmbHxWdgcRhQzUOK2Pf8tgOuOiIk/1rmqDffkt+WHyeTzvTCAQsp4CWVpii6 MQ9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=XfrvRCaDVt0vaUpu/TrPTSsdTK4AyptrJIe236pKe8U=; b=bbvHSciLsudkLMqNJwp8ua2Q7YwfrzeXDy7DK3ov7Nme6yGmoW5Bihxk6a8lFMFjH+ 4VC3XcifTnNEth9xEDk0sBGG3Sc1xTd317VHRuyh4O84HqBHEQlYmccAHt4PjKJPaK6Z tNLrto0AockCnNGdyY59mOX3ywW1ol2u5mZkQtKAdwgw/JHwB2kl1D6hOm5kfvjMdxXH GKxENhLEA2tgV97wqA4hSvCQgsEPboSMNDSKwkR/1FFpuNQCBiJrkrPRQ9Roh8fpbLLp a15vI23oIeKYneAxF1EAjWv7hbNLZDZndBO3e7VmkcoGcbc0lsCn9iaM6eeCHYxIQyxf lcdA== X-Gm-Message-State: AKS2vOyYLWqvJNZ84YQmtn5oNwbr++b52N97ePA+IvwiCvZ5PkQKak+l ctLN9o9BVgpKcTSSwmA= X-Received: by 10.200.40.251 with SMTP id j56mr2606722qtj.186.1497385628952; Tue, 13 Jun 2017 13:27:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 13 Jun 2017 13:26:59 -0700 Message-Id: <20170613202659.1920-4-rth@twiddle.net> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170613202659.1920-1-rth@twiddle.net> References: <20170613202659.1920-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::241 Subject: [Qemu-devel] [PULL 3/3] s390x/cpumodel: wire up cpu type + id for TCG X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Let's properly expose the CPU type (machine-type number) via "STORE CPU ID" and "STORE SUBSYSTEM INFORMATION". As TCG emulates basic mode, the CPU identification number has the format "Annnnn", whereby A is the CPU address, and n are parts of the CPU serial number (0 for us for now). A specification exception will be injected if the address is not aligned to a double word. Low address protection will not be checked as we're missing some more general support for that. Signed-off-by: David Hildenbrand Message-Id: <20170609133426.11447-3-david@redhat.com> Signed-off-by: Richard Henderson --- target/s390x/cpu.h | 2 +- target/s390x/cpu_models.c | 8 ++++++-- target/s390x/insn-data.def | 2 +- target/s390x/misc_helper.c | 9 ++++++--- target/s390x/translate.c | 9 ++------- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 2954974..a4028fb 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -149,7 +149,7 @@ typedef struct CPUS390XState { CPU_COMMON =20 uint32_t cpu_num; - uint32_t machine_type; + uint64_t cpuid; =20 uint64_t tod_offset; uint64_t tod_basetime; diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index b34318f..478bcc6 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -737,8 +737,6 @@ static inline void apply_cpu_model(const S390CPUModel *= model, Error **errp) =20 if (kvm_enabled()) { kvm_s390_apply_cpu_model(model, errp); - } else if (model) { - /* FIXME TCG - use data for stdip/stfl */ } =20 if (!*errp) { @@ -786,6 +784,12 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp) } =20 apply_cpu_model(cpu->model, errp); + + cpu->env.cpuid =3D s390_cpuid_from_cpu_model(cpu->model); + if (tcg_enabled()) { + /* basic mode, write the cpu address into the first 4 bit of the I= D */ + cpu->env.cpuid =3D deposit64(cpu->env.cpuid, 54, 4, cpu->env.cpu_n= um); + } } =20 static void get_feature(Object *obj, Visitor *v, const char *name, diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index 73dd05d..d089707 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -960,7 +960,7 @@ /* STORE CPU ADDRESS */ C(0xb212, STAP, S, Z, la2, 0, new, m1_16, stap, 0) /* STORE CPU ID */ - C(0xb202, STIDP, S, Z, la2, 0, new, m1_64, stidp, 0) + C(0xb202, STIDP, S, Z, la2, 0, new, 0, stidp, 0) /* STORE CPU TIMER */ C(0xb209, STPT, S, Z, la2, 0, new, m1_64, stpt, 0) /* STORE FACILITY LIST */ diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c index 4daa016..b508101 100644 --- a/target/s390x/misc_helper.c +++ b/target/s390x/misc_helper.c @@ -378,6 +378,7 @@ uint64_t HELPER(stpt)(CPUS390XState *env) uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0, uint64_t r0, uint64_t r1) { + S390CPU *cpu =3D s390_env_get_cpu(env); int cc =3D 0; int sel1, sel2; =20 @@ -397,12 +398,14 @@ uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0, if ((sel1 =3D=3D 1) && (sel2 =3D=3D 1)) { /* Basic Machine Configuration */ struct sysib_111 sysib; + char type[5] =3D {}; =20 memset(&sysib, 0, sizeof(sysib)); ebcdic_put(sysib.manuf, "QEMU ", 16); - /* same as machine type number in STORE CPU ID */ - ebcdic_put(sysib.type, "QEMU", 4); - /* same as model number in STORE CPU ID */ + /* same as machine type number in STORE CPU ID, but in EBCDIC = */ + snprintf(type, ARRAY_SIZE(type), "%X", cpu->model->def->type); + ebcdic_put(sysib.type, type, 4); + /* model number (not stored in STORE CPU ID for z/Architecure)= */ ebcdic_put(sysib.model, "QEMU ", 16); ebcdic_put(sysib.sequence, "QEMU ", 16); ebcdic_put(sysib.plant, "QEMU", 4); diff --git a/target/s390x/translate.c b/target/s390x/translate.c index d2917e4..8c055b7 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -3876,14 +3876,9 @@ static ExitStatus op_stctl(DisasContext *s, DisasOps= *o) =20 static ExitStatus op_stidp(DisasContext *s, DisasOps *o) { - TCGv_i64 t1 =3D tcg_temp_new_i64(); - check_privileged(s); - tcg_gen_ld32u_i64(o->out, cpu_env, offsetof(CPUS390XState, cpu_num)); - tcg_gen_ld32u_i64(t1, cpu_env, offsetof(CPUS390XState, machine_type)); - tcg_gen_deposit_i64(o->out, o->out, t1, 32, 32); - tcg_temp_free_i64(t1); - + tcg_gen_ld_i64(o->out, cpu_env, offsetof(CPUS390XState, cpuid)); + tcg_gen_qemu_st_i64(o->out, o->addr1, get_mem_index(s), MO_TEQ | MO_AL= IGN); return NO_EXIT; } =20 --=20 2.9.4