From nobody Thu May 2 21:02:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1685636846; cv=none; d=zohomail.com; s=zohoarc; b=cD5cbCfuX8cTlfHiefbNf8gjGbcT804AjsIFs9fh7vriIf0Q8Bn1S/dpBv4gGGPPUfONSdd3PvJBFmio2GQ03Fu31oFuVtfqa6yCEcFKE/Vtloizd+SKAfENapPmY8FemhyEIjYuZA/4kbM4EkEYjObYKgIFbuvQDycBKhXKcfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685636846; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=grDo/rhldMf7MtETJfVDpiwIhxhJY26o1W8IPAVQ/GE=; b=P3sEJXfN1OTp8HNL9DefKKeUL1MKIjwrqPde1gtXKQ+yusrg99p2Eropixdd4rPP09RbsGNenQbrctGVgzyIIOK627f5euXBf1/0AO8Vlfyr9xpv70Mmg8gqzotwPGbfD8OkxG3Ali3/shBxGsNoYwILZuZfDnl1LGeitovfQQ4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685636845993522.7004978734905; Thu, 1 Jun 2023 09:27:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4l7j-0003XX-AU; Thu, 01 Jun 2023 12:26:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4l7f-0003UD-Ev; Thu, 01 Jun 2023 12:26:01 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4l7c-00062C-LC; Thu, 01 Jun 2023 12:25:59 -0400 Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 351GELGF030680; Thu, 1 Jun 2023 16:25:54 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qxxp10akp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Jun 2023 16:25:53 +0000 Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 351GFc5o001654; Thu, 1 Jun 2023 16:25:53 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qxxp10aju-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Jun 2023 16:25:53 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3510vbbQ006682; Thu, 1 Jun 2023 16:25:51 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3qu94e2mju-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Jun 2023 16:25:51 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 351GPnWP43450804 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 1 Jun 2023 16:25:49 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 09FFD2004D; Thu, 1 Jun 2023 16:25:49 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9155F20040; Thu, 1 Jun 2023 16:25:48 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.171.86.130]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 1 Jun 2023 16:25:48 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=grDo/rhldMf7MtETJfVDpiwIhxhJY26o1W8IPAVQ/GE=; b=RGNWMOrbzDJz2IPiCHhcSBx2ssxbkmRdU1rncGOOjiwjV0XMHDWWEYU82RKhtcnehlsG Oi/xMXV1TlsmB+grRWtnHJrUQaZdI2iwwn94vnq7rjBsaC/wlZXVVRGOinkTqg4kkiiW jaL5cSChiqRkv8xIKwiFnEdZbpJ5CcNwFeYhO1PkDLI433GsLfo4bqkTfTu5mTFUYn4P sGND9ir4LdMp43ygPG6JPukoy+0ypn6t3htfs/I4T8Yl/Shl65cbePX1KGl8YEdvhuKc cjRhNmVRieQUGUazgdtl+Oy3S+KeLElO2wYC1FpVJwfsyZHGnWjAd1bA1K2UWhpGYnmf mA== From: Ilya Leoshkevich To: Laurent Vivier , David Hildenbrand , Thomas Huth , Richard Henderson Cc: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, Ilya Leoshkevich Subject: [PATCH 1/4] s390x/tcg: Fix CPU address returned by STIDP Date: Thu, 1 Jun 2023 18:25:38 +0200 Message-Id: <20230601162541.689621-2-iii@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601162541.689621-1-iii@linux.ibm.com> References: <20230601162541.689621-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: cE1pggHTdAI76k9diCW24_Sr8flRPXQU X-Proofpoint-ORIG-GUID: qGAWVzpBVuOyuIFKmu_p2Cf-gcq5LBnC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-01_08,2023-05-31_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 mlxscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxlogscore=828 phishscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306010139 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=iii@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1685636847377100019 Content-Type: text/plain; charset="utf-8" In qemu-user-s390x, /proc/cpuinfo contains: cpu number : 0 identification : 000000 cpu number : 1 identification : 400000 The highest nibble is supposed to contain the CPU address, but it's off by 2 bits. Fix the shift value and provide a symbolic constant for it. Fixes: 076d4d39b65f ("s390x/cpumodel: wire up cpu type + id for TCG") Signed-off-by: Ilya Leoshkevich Reviewed-by: David Hildenbrand --- target/s390x/cpu_models.c | 4 ++-- target/s390x/cpu_models.h | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 457b5cb10c4..ae8880e81dc 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -607,8 +607,8 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp) #if !defined(CONFIG_USER_ONLY) 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.core_= id); + cpu->env.cpuid =3D deposit64(cpu->env.cpuid, CPU_PHYS_ADDR_SHIFT, + CPU_PHYS_ADDR_BITS, cpu->env.core_id); } #endif } diff --git a/target/s390x/cpu_models.h b/target/s390x/cpu_models.h index fb1adc8b210..cc7305ec213 100644 --- a/target/s390x/cpu_models.h +++ b/target/s390x/cpu_models.h @@ -96,10 +96,18 @@ static inline bool s390_known_cpu_type(uint16_t type) { return s390_get_gen_for_cpu_type(type) !=3D 0; } +#define CPU_ID_SHIFT 32 +#define CPU_ID_BITS 24 +/* + * When cpu_id_format is 0 (basic mode), the leftmost 4 bits of cpu_id con= tain + * the rightmost 4 bits of the physical CPU address. + */ +#define CPU_PHYS_ADDR_BITS 4 +#define CPU_PHYS_ADDR_SHIFT (CPU_ID_SHIFT + CPU_ID_BITS - CPU_PHYS_ADDR_BI= TS) static inline uint64_t s390_cpuid_from_cpu_model(const S390CPUModel *model) { return ((uint64_t)model->cpu_ver << 56) | - ((uint64_t)model->cpu_id << 32) | + ((uint64_t)model->cpu_id << CPU_ID_SHIFT) | ((uint64_t)model->def->type << 16) | (model->def->gen =3D=3D 7 ? 0 : (uint64_t)model->cpu_id_format = << 15); } --=20 2.40.1 From nobody Thu May 2 21:02:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1685636840; cv=none; d=zohomail.com; s=zohoarc; b=gU8rukpawtUIV/gNP1tEhKnhfZKyoE0CI/VXTG90+/0Hta6ZlaWk0wyiNbG21hR1hsz1YgIFtV0TV+QEe2OpIobqDPHBrhK2Dnt/lioY5TIkrX2WWYsLKkN64yvaGb+CrGr5/vVeaFtcABbC1yHLSZUnl1DylR3+kuQSB/BSDZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685636840; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rtNBVnsFazn1pD1wC2LLAqVhPLfBxFMSUBohEltDyKo=; b=YVLrLAfAa4JD6itpvH78ADXkYo7vLwJEK5ManqV14SCBAL2OXG/Q0CsbE8AEsGpaeejRe0cgxvJzZRxCfw4dnQs9tyBCN35YzYRpibVYvvePdtXvcb2rqDt9TPBkQ7T1iSWTNWXdCcpn7tla2DhOGjipoQueOTgP9GbvXHTE3ec= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685636840025313.7425920990984; Thu, 1 Jun 2023 09:27:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4l7k-0003b8-DT; Thu, 01 Jun 2023 12:26:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4l7h-0003Vn-TH; Thu, 01 Jun 2023 12:26:01 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4l7e-00065F-Pf; Thu, 01 Jun 2023 12:26:00 -0400 Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 351GEorh014068; Thu, 1 Jun 2023 16:25:56 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qxxpc09fe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Jun 2023 16:25:55 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 351GJA52024401; Thu, 1 Jun 2023 16:25:55 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qxxpc09e5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Jun 2023 16:25:55 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 35196vBw018354; Thu, 1 Jun 2023 16:25:53 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma03fra.de.ibm.com (PPS) with ESMTPS id 3qu9g5a5y7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Jun 2023 16:25:52 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 351GPoa621693020 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 1 Jun 2023 16:25:50 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 96D6020040; Thu, 1 Jun 2023 16:25:50 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 20D0F20043; Thu, 1 Jun 2023 16:25:50 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.171.86.130]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 1 Jun 2023 16:25:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=rtNBVnsFazn1pD1wC2LLAqVhPLfBxFMSUBohEltDyKo=; b=eyGx6WnsmGFxOf+oCgSBEsNZFiASTEVmhjuDLp7R2Xb6UQEojMU5tWgqPtRHWICW/ZhE Ic/DwfilS+3Sx5v1dHKSTxqODGsN9C170b4ghiYLb4t+TuCZX0kagjNxC8WIKKPKpXwM GjQKTqbBVKytZqNJQnLXN91CbUTYzrTaN/rglV3Ia3RcrZxQcmZLbTNkRnQxZ6PxLXQ3 flwI+wti49okguXRbOTeUrwAF2IQoaffJNAcFK1NKDPF4aB4D1cXvbL0djaEFGcnQgaJ s9Dl2G4pzXRFG3SMNQXySQvau/l0RzD9EGUGcDfnNmX9yPLfeUtLpdGfcP894FG19s8A Ig== From: Ilya Leoshkevich To: Laurent Vivier , David Hildenbrand , Thomas Huth , Richard Henderson Cc: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, Ilya Leoshkevich Subject: [PATCH 2/4] linux-user/elfload: Expose get_elf_hwcap() on s390x Date: Thu, 1 Jun 2023 18:25:39 +0200 Message-Id: <20230601162541.689621-3-iii@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601162541.689621-1-iii@linux.ibm.com> References: <20230601162541.689621-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: jnEd3HPWBU8af0-MwHcZYnM-b7cTHe63 X-Proofpoint-GUID: 29YPBAA8CIBA1FDdzXmx9-fo1RiuMxbb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-01_08,2023-05-31_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 clxscore=1015 mlxlogscore=999 impostorscore=0 spamscore=0 adultscore=0 mlxscore=0 suspectscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306010139 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=iii@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1685636842115100007 Content-Type: text/plain; charset="utf-8" It is required for implementing /proc/cpuinfo emulation. Signed-off-by: Ilya Leoshkevich Reviewed-by: David Hildenbrand --- linux-user/elfload.c | 2 +- linux-user/loader.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 418ad92598c..49ec9ccc944 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1583,7 +1583,7 @@ static inline void init_thread(struct target_pt_regs = *regs, #define GET_FEATURE(_feat, _hwcap) \ do { if (s390_has_feat(_feat)) { hwcap |=3D _hwcap; } } while (0) =20 -static uint32_t get_elf_hwcap(void) +uint32_t get_elf_hwcap(void) { /* * Let's assume we always have esan3 and zarch. diff --git a/linux-user/loader.h b/linux-user/loader.h index f375ee0679b..ad6ca9dbe35 100644 --- a/linux-user/loader.h +++ b/linux-user/loader.h @@ -56,4 +56,8 @@ abi_long memcpy_to_target(abi_ulong dest, const void *src, =20 extern unsigned long guest_stack_size; =20 +#ifdef TARGET_S390X +uint32_t get_elf_hwcap(void); +#endif + #endif /* LINUX_USER_LOADER_H */ --=20 2.40.1 From nobody Thu May 2 21:02:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1685636842; cv=none; d=zohomail.com; s=zohoarc; b=jk51ESiudkthlp3rxEhiNzgtyUxJ0CDdM+N3dv5VNe86OpbyMj1mI0byAidib60dA/l+9cLexCsO9pjV+WJ7g0auglGxqyFeZLUS1NP2SYRwKlbwgKJDFmngMbjHIHncusK4SrhzhEv5fJGkHYPHDbx9OUNgEyAsslQ2nPkuMLw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685636842; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AebpaopUxRz1TlZoHuaRg05fUD2N67PSzJwMozudzrU=; b=VHsSj1VeHqRZ+Q1vD3/Ty7rdAmG9bW9jVpiiR0Nnat5oEayBEhAlKzC6THgAESTGt2pvLlOspAqdDgvctzoxWezPobR7gmhumHdBkxarXw/m7TOGR0IpOaYF/u5djFjWvZiQAEcep12eev3ygP1TTZ4qTJ53RAv0RJFy2EMGN3Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685636842252914.4880673722496; Thu, 1 Jun 2023 09:27:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4l7n-0003k3-Ht; Thu, 01 Jun 2023 12:26:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4l7k-0003bK-Ro; Thu, 01 Jun 2023 12:26:04 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4l7h-00066X-VD; Thu, 01 Jun 2023 12:26:04 -0400 Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 351GPD17019287; Thu, 1 Jun 2023 16:25:58 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qxx81s3m5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Jun 2023 16:25:57 +0000 Received: from m0353727.ppops.net (m0353727.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 351G7I2d022405; Thu, 1 Jun 2023 16:25:57 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qxx81s3jt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Jun 2023 16:25:57 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3513vaCs022654; Thu, 1 Jun 2023 16:25:54 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma02fra.de.ibm.com (PPS) with ESMTPS id 3qu9g526pa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Jun 2023 16:25:54 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 351GPqwe18416138 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 1 Jun 2023 16:25:52 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2079D20043; Thu, 1 Jun 2023 16:25:52 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A0B232004B; Thu, 1 Jun 2023 16:25:51 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.171.86.130]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 1 Jun 2023 16:25:51 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=AebpaopUxRz1TlZoHuaRg05fUD2N67PSzJwMozudzrU=; b=Z0Dg7oR4CkV8zWmxWej+O55A/8SZ1BO1uRhkteNsl8SO8qSeTjjOhdiy3pWlW8+bFtCf Uctg3aGCW0KWBiWuycFq/LnPCMSqrgtwqMrKWrY0WnCf8knIyTMB5vK3UHJpFDAdbXBd i2byMmrSWxI4ML0jdjfE5YcWQ55yQypcIcyrLLjOBFWFqE4n6jv/dKjN6TdilnP/zz2C 1rG8BBc2xX+30HRGIom0MvTD57w2uUIvQZ4A54McXxMZDta99/i5STzCsi22fg6x0wKn P/blEmdkrf2QDMJalErEP9WtpCXJgPYjKEoVwsRdlHzC2R803E13ixR9qzeyFvzoL3zX rA== From: Ilya Leoshkevich To: Laurent Vivier , David Hildenbrand , Thomas Huth , Richard Henderson Cc: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, Ilya Leoshkevich Subject: [PATCH 3/4] linux-user/elfload: Introduce elf_hwcap_str() on s390x Date: Thu, 1 Jun 2023 18:25:40 +0200 Message-Id: <20230601162541.689621-4-iii@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601162541.689621-1-iii@linux.ibm.com> References: <20230601162541.689621-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: hlVSEysLu8fevxL5VCrrTQYiUkB5V1tB X-Proofpoint-GUID: YlY1oJ1XiHTkilQV8yq5wXmbo1REs-Ub X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-01_08,2023-05-31_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 clxscore=1015 mlxlogscore=999 malwarescore=0 impostorscore=0 mlxscore=0 phishscore=0 bulkscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306010139 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=iii@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1685636843668100011 Content-Type: text/plain; charset="utf-8" It is required for implementing /proc/cpuinfo emulation. Signed-off-by: Ilya Leoshkevich Reviewed-by: David Hildenbrand --- linux-user/elfload.c | 27 +++++++++++++++++++++++++++ linux-user/loader.h | 1 + 2 files changed, 28 insertions(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 49ec9ccc944..d80d68484b6 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1605,6 +1605,33 @@ uint32_t get_elf_hwcap(void) return hwcap; } =20 +const char *elf_hwcap_str(uint32_t bit) +{ + static const char *hwcap_str[] =3D { + [HWCAP_S390_ESAN3] =3D "esan3", + [HWCAP_S390_ZARCH] =3D "zarch", + [HWCAP_S390_STFLE] =3D "stfle", + [HWCAP_S390_MSA] =3D "msa", + [HWCAP_S390_LDISP] =3D "ldisp", + [HWCAP_S390_EIMM] =3D "eimm", + [HWCAP_S390_DFP] =3D "dfp", + [HWCAP_S390_HPAGE] =3D "edat", + [HWCAP_S390_ETF3EH] =3D "etf3eh", + [HWCAP_S390_HIGH_GPRS] =3D "highgprs", + [HWCAP_S390_TE] =3D "te", + [HWCAP_S390_VXRS] =3D "vx", + [HWCAP_S390_VXRS_BCD] =3D "vxd", + [HWCAP_S390_VXRS_EXT] =3D "vxe", + [HWCAP_S390_GS] =3D "gs", + [HWCAP_S390_VXRS_EXT2] =3D "vxe2", + [HWCAP_S390_VXRS_PDE] =3D "vxp", + [HWCAP_S390_SORT] =3D "sort", + [HWCAP_S390_DFLT] =3D "dflt", + }; + + return bit < ARRAY_SIZE(hwcap_str) ? hwcap_str[bit] : NULL; +} + static inline void init_thread(struct target_pt_regs *regs, struct image_i= nfo *infop) { regs->psw.addr =3D infop->entry; diff --git a/linux-user/loader.h b/linux-user/loader.h index ad6ca9dbe35..59cbeacf24f 100644 --- a/linux-user/loader.h +++ b/linux-user/loader.h @@ -58,6 +58,7 @@ extern unsigned long guest_stack_size; =20 #ifdef TARGET_S390X uint32_t get_elf_hwcap(void); +const char *elf_hwcap_str(uint32_t bit); #endif =20 #endif /* LINUX_USER_LOADER_H */ --=20 2.40.1 From nobody Thu May 2 21:02:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1685636846; cv=none; d=zohomail.com; s=zohoarc; b=mmjxSGFqWVSExuIRyVMBwxDvj52aYDy11ko/j2Mco11r3PX6sAtjDXIuVzEM9b/qr/9QrDdFrdJx2VBV/kqd5e4Fz9w8IXHB5B6WLXWN/giKKL9sPI2WrKbSidNr1n5Y/dzbsC2BjWrcLBe1MoM4ViCnZQsuXPVQPKsVaVu/AEc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685636846; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ce/oCkaRePMvEAe1YlqI4oVPmWA610yYfHNBkb/YWx8=; b=WxOWwmuw3D5it4sCzZibb+I465qcMaV9mEClwr2rP4V/iPKbDMWxaiQ/YC60ySEJNrryTzIjxUA232oeeEYrEzgmAvhcxREl19IxwXBm785k1jcTl9YLuxrzDh7NW9IKFGP/rpx+TAoLMF66Hq6+q+W43Visvr1n3yrTvR/01Ko= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685636846164448.8531977683567; Thu, 1 Jun 2023 09:27:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4l7l-0003ez-Ql; Thu, 01 Jun 2023 12:26:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4l7j-0003Zt-O1; Thu, 01 Jun 2023 12:26:03 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4l7h-00066y-U2; Thu, 01 Jun 2023 12:26:03 -0400 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 351GHGWU004382; Thu, 1 Jun 2023 16:25:58 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qxxqj87j7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Jun 2023 16:25:58 +0000 Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 351GIrLo009244; Thu, 1 Jun 2023 16:25:58 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qxxqj87hm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Jun 2023 16:25:58 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 351CeEjp005447; Thu, 1 Jun 2023 16:25:56 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma03ams.nl.ibm.com (PPS) with ESMTPS id 3qu9g52mwx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Jun 2023 16:25:55 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 351GPraC38142224 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 1 Jun 2023 16:25:53 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 89E532004E; Thu, 1 Jun 2023 16:25:53 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0A4422004B; Thu, 1 Jun 2023 16:25:53 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.171.86.130]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 1 Jun 2023 16:25:52 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=ce/oCkaRePMvEAe1YlqI4oVPmWA610yYfHNBkb/YWx8=; b=LG7rAL9eYPE8qTw5C53IjOq+Fj9L5DPOZ/rozeehiGRc9wJIDGhNPmER5PuhhCtsCews D/JhEY/Adr2kP9jYz3qvY3fkBq5k6d1LnzbOOF2+4xnWdMqg38ovgx14KEt+m9RuH1fx AKEqJnYc8ZzdYb1fSN2Fv3Q1SJjMykLcgWu9Cn7aTQ+aW3NByS6IzW8MTZdyIhlIcIcx 1fkAKUj6UR7OAWzZO5i+C2wdt4ls2BZi59Goe5JjKzCA65+SyI1nohlHxXPz8mT+praq LAnc7me8Gsda79iGiphQLyNJ9p1yqNPNhGE6bUNriUJRt3C1WwVTXeX2M7VqkUGSsqnR 1Q== From: Ilya Leoshkevich To: Laurent Vivier , David Hildenbrand , Thomas Huth , Richard Henderson Cc: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, Ilya Leoshkevich , Tulio Magno Quites Machado Filho Subject: [PATCH 4/4] linux-user: Emulate /proc/cpuinfo on s390x Date: Thu, 1 Jun 2023 18:25:41 +0200 Message-Id: <20230601162541.689621-5-iii@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601162541.689621-1-iii@linux.ibm.com> References: <20230601162541.689621-1-iii@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: e4Tmrv7SVBo2PeYQ0azPVldDsijVxgR5 X-Proofpoint-GUID: KRs-uS0zXwCfSLkv721Hr3xzFJkWDSgm Content-Transfer-Encoding: quoted-printable X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-01_08,2023-05-31_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 spamscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306010139 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=iii@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1685636847394100020 Content-Type: text/plain; charset="utf-8" Some s390x userspace programs are confused when seeing a foreign /proc/cpuinfo [1]. Add the emulation for s390x; follow the respective kernel code structure where possible. [1] https://bugzilla.redhat.com/show_bug.cgi?id=3D2211472 Reported-by: Tulio Magno Quites Machado Filho Signed-off-by: Ilya Leoshkevich Reviewed-by: David Hildenbrand --- linux-user/syscall.c | 106 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 105 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 3e6ed51ce62..d142e09dc70 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8339,6 +8339,109 @@ static int open_cpuinfo(CPUArchState *cpu_env, int = fd) } #endif =20 +#if defined(TARGET_S390X) +/* + * Emulate what a Linux kernel running in qemu-system-s390x -M accel=3Dtcg= would + * show in /proc/cpuinfo. + * + * Skip the following in order to match the missing support in op_ecag(): + * - show_cacheinfo(). + * - show_cpu_topology(). + * - show_cpu_mhz(). + * + * Use fixed values for certain fields: + * - bogomips per cpu - from a qemu-system-s390x run. + * - max thread id =3D 0, since SMT / SIGP_SET_MULTI_THREADING is not supp= orted. + * + * Keep the code structure close to arch/s390/kernel/processor.c. + */ + +static void show_facilities(int fd) +{ + size_t sizeof_stfl_bytes =3D 2048; + g_autofree uint8_t *stfl_bytes =3D g_new0(uint8_t, sizeof_stfl_bytes); + unsigned int bit; + + dprintf(fd, "facilities :"); + s390_get_feat_block(S390_FEAT_TYPE_STFL, stfl_bytes); + for (bit =3D 0; bit < sizeof_stfl_bytes * 8; bit++) { + if (test_be_bit(bit, stfl_bytes)) { + dprintf(fd, " %d", bit); + } + } + dprintf(fd, "\n"); +} + +static int cpu_ident(unsigned long n) +{ + return deposit32(0, CPU_ID_BITS - CPU_PHYS_ADDR_BITS, CPU_PHYS_ADDR_BI= TS, + n); +} + +static void show_cpu_summary(CPUArchState *cpu_env, int fd) +{ + S390CPUModel *model =3D env_archcpu(cpu_env)->model; + int num_cpus =3D sysconf(_SC_NPROCESSORS_ONLN); + uint32_t elf_hwcap =3D get_elf_hwcap(); + const char *hwcap_str; + int i; + + dprintf(fd, "vendor_id : IBM/S390\n" + "# processors : %i\n" + "bogomips per cpu: 13370.00\n", + num_cpus); + dprintf(fd, "max thread id : 0\n"); + dprintf(fd, "features\t: "); + for (i =3D 0; i < sizeof(elf_hwcap) * 8; i++) { + if (!(elf_hwcap & (1 << i))) { + continue; + } + hwcap_str =3D elf_hwcap_str(i); + if (hwcap_str) { + dprintf(fd, "%s ", hwcap_str); + } + } + dprintf(fd, "\n"); + show_facilities(fd); + for (i =3D 0; i < num_cpus; i++) { + dprintf(fd, "processor %d: " + "version =3D %02X, " + "identification =3D %06X, " + "machine =3D %04X\n", + i, model->cpu_ver, cpu_ident(i), model->def->type); + } +} + +static void show_cpu_ids(CPUArchState *cpu_env, int fd, unsigned long n) +{ + S390CPUModel *model =3D env_archcpu(cpu_env)->model; + + dprintf(fd, "version : %02X\n", model->cpu_ver); + dprintf(fd, "identification : %06X\n", cpu_ident(n)); + dprintf(fd, "machine : %04X\n", model->def->type); +} + +static void show_cpuinfo(CPUArchState *cpu_env, int fd, unsigned long n) +{ + if (n =3D=3D 0) { + show_cpu_summary(cpu_env, fd); + } + dprintf(fd, "\ncpu number : %ld\n", n); + show_cpu_ids(cpu_env, fd, n); +} + +static int open_cpuinfo(CPUArchState *cpu_env, int fd) +{ + int num_cpus =3D sysconf(_SC_NPROCESSORS_ONLN); + int i; + + for (i =3D 0; i < num_cpus; i++) { + show_cpuinfo(cpu_env, fd, i); + } + return 0; +} +#endif + #if defined(TARGET_M68K) static int open_hardware(CPUArchState *cpu_env, int fd) { @@ -8364,7 +8467,8 @@ int do_guest_openat(CPUArchState *cpu_env, int dirfd,= const char *pathname, #if HOST_BIG_ENDIAN !=3D TARGET_BIG_ENDIAN { "/proc/net/route", open_net_route, is_proc }, #endif -#if defined(TARGET_SPARC) || defined(TARGET_HPPA) || defined(TARGET_RISCV) +#if defined(TARGET_SPARC) || defined(TARGET_HPPA) || \ + defined(TARGET_RISCV) || defined(TARGET_S390X) { "/proc/cpuinfo", open_cpuinfo, is_proc }, #endif #if defined(TARGET_M68K) --=20 2.40.1