From nobody Wed Nov 27 21:34:02 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=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1697666287; cv=none; d=zohomail.com; s=zohoarc; b=eOqEp0AqtyicYTCIsA3duguu56mDcjv1ITRbrCeHewJjSHvWTkr6pY8mnK6hH3HfX5YCS1MEL1YreIb2a5LAp38WUqFTQZc9Rrw1yOHBpoOLVjb4E2Z5GXkeISlX3kZ7zxyRB0GYYdaDQo1olv+4cHJzEFSA3yxHKCmCyQHrZlg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697666287; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KPk9VlCAjpCD8p3ZbSvb+o08mQKrjmWkggjvcwFuWFk=; b=jm5QPvt7ds3m6IKs9CeGOjFsw3+V0rgeI6sUKkqSWF+odkYF53Azz+KO5RlzR2VZykV8KuVXcrXxvpAI1BmbPBJJ1j5D5ZgMwoLO6ik3eqJCT+g615+d/j3nICDF8xJa8bmcjAERp4XHjg/vqzjEEJX5kBeONBOo49BW+h2LxXQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697666287219880.5627854920837; Wed, 18 Oct 2023 14:58:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtESg-0001ml-Il; Wed, 18 Oct 2023 17:52:18 -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 1qtESH-00017b-7z for qemu-devel@nongnu.org; Wed, 18 Oct 2023 17:51:54 -0400 Received: from mail-oo1-xc2b.google.com ([2607:f8b0:4864:20::c2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtESF-0004P8-IL for qemu-devel@nongnu.org; Wed, 18 Oct 2023 17:51:53 -0400 Received: by mail-oo1-xc2b.google.com with SMTP id 006d021491bc7-57f02eeabcaso4483952eaf.0 for ; Wed, 18 Oct 2023 14:51:50 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id w17-20020a63f511000000b005b61a024ec7sm2176380pgh.74.2023.10.18.14.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 14:51:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697665910; x=1698270710; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KPk9VlCAjpCD8p3ZbSvb+o08mQKrjmWkggjvcwFuWFk=; b=rFx9Bv/MTRbEoI4GcHbtb8Ev+Jvvyq9OUZ/WSft2c1xZ2FC8EZ5GtC3iS5bt702Tzg osooo9FGLK2xF8Z6TZe4VFDx8AX4Him8ctHBKa+1zgfWg7EuiCwvGu/0pv2NipOJBFui Hmt4fjUje5lzW1ddI6fKVOIpmU0bG/hIoJ+qgyPCde2XGDnJqpuht6C4S/waMDFo8OKA XnRcjLzUB6P5BHFr+I52wDPZid/WTAWFdJorKnqYLUKz8Bpp6mvLQCekumga8T0deIHq 7BRgIbcMHzIC/X3iwVMMOdRpo/4AOTpMjj/BXfFLRn/MNSVXVnPetiu8avsdVLwJb2qc oMww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697665910; x=1698270710; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KPk9VlCAjpCD8p3ZbSvb+o08mQKrjmWkggjvcwFuWFk=; b=fg7Qup6fkhUljhWWztdEq5p/6iwHB+bcK/tzTHZkwpNe/WzRLVv9TJp+zqWkXD5cqD pRv25h2cDaOC2l2C6Uo3yavJi/+RA92LZMPLaF6exnGAxzztos1eS75wZjBw2MecoGCs SIr4lPkBvNuca6/IsQOAy3wOlPmU4l6WRkOE5IBGB0mPtam7NxMYY1A7Q7DBqLU2AyO9 5Bw3bKTrvcWzW58nmZ4pFGDz8xmB3dcxBUpweaEEd8uXWW8Sq29FDCYDu6Y0wLwexTME 1Cc8O+RyhG3yNrhgik+5ZYCnwD2ErTvbSPTZDSiUbvE7F7YVb0W+xRVxC6ymIy2X9ice xf6w== X-Gm-Message-State: AOJu0Yy8+ygBWLd5SHp7rcM0WVnPHe7FwrkYGhWT4j3A/yD8KQAJNqjN Hw56SXg8EmFqvHj6PyyKUFfvJ5w7QSs8W3liZPk= X-Google-Smtp-Source: AGHT+IEu6lRcHaIH6mRZQWe+8u9dv1OSOVnVU2fUalGkde9aQEE9LM9o15ALjEopuAivZFuX5aQ4Dw== X-Received: by 2002:a05:6359:6e8c:b0:166:e779:7ce7 with SMTP id ti12-20020a0563596e8c00b00166e7797ce7mr212479rwb.32.1697665909864; Wed, 18 Oct 2023 14:51:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@gmx.de Subject: [PATCH 16/61] target/hppa: Update cpu_hppa_get/put_psw for hppa64 Date: Wed, 18 Oct 2023 14:50:50 -0700 Message-Id: <20231018215135.1561375-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231018215135.1561375-1-richard.henderson@linaro.org> References: <20231018215135.1561375-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::c2b; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc2b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 @linaro.org) X-ZM-MESSAGEID: 1697666289442100003 Content-Type: text/plain; charset="utf-8" With 64-bit registers, there are 16 carry bits in the PSW. Clear reserved bits based on cpu revision. Signed-off-by: Richard Henderson --- target/hppa/helper.c | 63 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 11 deletions(-) diff --git a/target/hppa/helper.c b/target/hppa/helper.c index a8d3f456ee..40e859ba08 100644 --- a/target/hppa/helper.c +++ b/target/hppa/helper.c @@ -28,19 +28,35 @@ target_ureg cpu_hppa_get_psw(CPUHPPAState *env) { target_ureg psw; + target_ureg mask1 =3D (target_ureg)-1 / 0xf; + target_ureg maskf =3D (target_ureg)-1 / 0xffff * 0xf; =20 /* Fold carry bits down to 8 consecutive bits. */ - /* ??? Needs tweaking for hppa64. */ - /* .......b...c...d...e...f...g...h */ - psw =3D (env->psw_cb >> 4) & 0x01111111; - /* .......b..bc..cd..de..ef..fg..gh */ + /* ^^^b^^^c^^^d^^^e^^^f^^^g^^^h^^^i^^^j^^^k^^^l^^^m^^^n^^^o^^^p^^^^ */ + /* ^^^b^^^c^^^d^^^e^^^f^^^g^^^h^^^^ */ + psw =3D (env->psw_cb >> 4) & mask1; + /* .......b...c...d...e...f...g...h...i...j...k...l...m...n...o...p */ + /* .......b...c...d...e...f...g...h */ psw |=3D psw >> 3; - /* .............bcd............efgh */ - psw |=3D (psw >> 6) & 0x000f000f; - /* .........................bcdefgh */ - psw |=3D (psw >> 12) & 0xf; - psw |=3D env->psw_cb_msb << 7; - psw =3D (psw & 0xff) << 8; + /* .......b..bc..cd..de..ef..fg..gh..hi..ij..jk..kl..lm..mn..no..op */ + /* .......b..bc..cd..de..ef..fg..gh */ + psw |=3D psw >> 6; + psw &=3D maskf; + /* .............bcd............efgh............ijkl............mnop */ + /* .............bcd............efgh */ + psw |=3D psw >> 12; + /* .............bcd.........bcdefgh........efghijkl........ijklmnop */ + /* .............bcd.........bcdefgh */ + psw |=3D env->psw_cb_msb << (TARGET_REGISTER_BITS =3D=3D 64 ? 39 : 7); + /* .............bcd........abcdefgh........efghijkl........ijklmnop */ + /* .............bcd........abcdefgh */ + + /* For hppa64, the two 8-bit fields are discontiguous. */ + if (env_archcpu(env)->is_pa20) { + psw =3D (psw & 0xff00000000ull) | ((psw & 0xff) << 8); + } else { + psw =3D (psw & 0xff) << 8; + } =20 psw |=3D env->psw_n * PSW_N; psw |=3D (env->psw_v < 0) * PSW_V; @@ -51,14 +67,39 @@ target_ureg cpu_hppa_get_psw(CPUHPPAState *env) =20 void cpu_hppa_put_psw(CPUHPPAState *env, target_ureg psw) { + uint64_t reserved; target_ureg old_psw =3D env->psw; target_ureg cb =3D 0; =20 + /* Do not allow reserved bits to be set. */ + if (env_archcpu(env)->is_pa20) { + reserved =3D MAKE_64BIT_MASK(40, 24) | MAKE_64BIT_MASK(28, 4); + reserved |=3D PSW_G; /* PA1.x only */ + reserved |=3D PSW_E; /* not implemented */ + } else { + reserved =3D MAKE_64BIT_MASK(32, 32) | MAKE_64BIT_MASK(28, 2); + reserved |=3D PSW_O | PSW_W; /* PA2.0 only */ + reserved |=3D PSW_E | PSW_Y | PSW_Z; /* not implemented */ + } + psw &=3D ~reserved; + env->psw =3D psw & ~(PSW_N | PSW_V | PSW_CB); env->psw_n =3D (psw / PSW_N) & 1; env->psw_v =3D -((psw / PSW_V) & 1); - env->psw_cb_msb =3D (psw >> 15) & 1; =20 +#if TARGET_REGISTER_BITS =3D=3D 32 + env->psw_cb_msb =3D (psw >> 15) & 1; +#else + env->psw_cb_msb =3D (psw >> 39) & 1; + cb |=3D ((psw >> 38) & 1) << 60; + cb |=3D ((psw >> 37) & 1) << 56; + cb |=3D ((psw >> 36) & 1) << 52; + cb |=3D ((psw >> 35) & 1) << 48; + cb |=3D ((psw >> 34) & 1) << 44; + cb |=3D ((psw >> 33) & 1) << 40; + cb |=3D ((psw >> 32) & 1) << 36; + cb |=3D ((psw >> 15) & 1) << 32; +#endif cb |=3D ((psw >> 14) & 1) << 28; cb |=3D ((psw >> 13) & 1) << 24; cb |=3D ((psw >> 12) & 1) << 20; --=20 2.34.1