From nobody Sat May 18 21:15:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1618465462; cv=none; d=zohomail.com; s=zohoarc; b=WdnZFJh768RMxq+GU0YbIaxItigJ3dC874EAHut7gv+HUcDeAl4vrPYYwqAbTOO+fYpFlN+lhJluUfgnH762Vjy7BKCIay7uuKpwo9hJGVwweFUM+HVAPnShHbgMDjgLLLbX23dEFNBML/IhwtO/8ocPaVmszZyWinBBakswBZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618465462; 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=ZY/g1DDp//F/F5LFsGZagO1HYB3lEEm5TGBFu+93DlY=; b=DrZuQRKVwnEdYq8Nm/6mo6lyIBJQwAHglifnXTdkbzBr3QffVlnCFwK7M5L7SHEMr6G+2kzcQtCKwtQxvw8jhHmPcbit7wYXmqeWoMKysmXMCp/bn08KOQ8hZAgS2yKzyYu4nEVZ97HG75iHLB77zLtaOEIti+SR+m5aisICeWc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1618465462841755.8840651291067; Wed, 14 Apr 2021 22:44:22 -0700 (PDT) Received: from localhost ([::1]:56366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lWund-0002N8-0D for importer@patchew.org; Thu, 15 Apr 2021 01:44:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lWumE-0000gE-Io; Thu, 15 Apr 2021 01:42:54 -0400 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]:39572) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lWumD-0007HX-3a; Thu, 15 Apr 2021 01:42:54 -0400 Received: by mail-pj1-x102f.google.com with SMTP id ot17-20020a17090b3b51b0290109c9ac3c34so13737710pjb.4; Wed, 14 Apr 2021 22:42:52 -0700 (PDT) Received: from bobo.ibm.com (193-116-90-211.tpgi.com.au. [193.116.90.211]) by smtp.gmail.com with ESMTPSA id c5sm946151pfp.183.2021.04.14.22.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Apr 2021 22:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZY/g1DDp//F/F5LFsGZagO1HYB3lEEm5TGBFu+93DlY=; b=a2dK6POTAtK9q1idOMQSvQCmYu/Doat/kKInI64gQgU3+ndR0DZaKIlv74aOa5M0Sz Fj8HneL14GuV1T/2ROEswJfNlOBQQSB0dqDYTOoUUnAANRCJVOOjP6U+9bVlNySJTEaL 458+RaKPMoBA7MrsCFz95cSw58Uf+rbAHyhxWb2Y9ED3FPXfMJqEMy5k0srRbse+rdZV 3I+8KJIjtBNbWmNOpr2kCEqCJIj0f/nlf7fSwXQwt5k49VhjMEpXDSNRmdFAfdkKW9gU Pp53aC0w3P1lXjlg9lAOxvk4llqWPkkhHIngw1fWs620sWwR4IkHOWbKqalIgJBtFN4B Mayw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZY/g1DDp//F/F5LFsGZagO1HYB3lEEm5TGBFu+93DlY=; b=kJx9Px+Jyl0rWemJBwmxjRQGGckQmAOiLGXRnlJnaj0u8H0hqqLnADzu73Df5xXcQL 9u1J6aot4WNcP4ae2BTtodxdyqouIyQYSH0/duI2nwfc6RJ/o8qXApGy5y6pNqiS3jtl hmmGpjD3iXZmiD6jwxKZISxJpQnkzKtf66Lcj8A15BA/VeRVJtS7I1zDGaS3EmtWiRhz rFqRYauNAFqsu4moPEgCV6EYDts/POTFElXIVxUtTavg5i3AI/NHYwrjDyKxo3SIWrfJ uD3BmKXpyN8yCQayLfqhzofsoaGaVFISJnu/IWs98FNb0lijhEvUyttHHt4K5M8DcOF/ YhpA== X-Gm-Message-State: AOAM533f/C3ikrx9Ub8qW6aPFDVUnyvpsx2D+9DMfLtNWqgzZfdSPUrD 5zxiqsssx/X8sVjKiRemYsqMdzZZgA4= X-Google-Smtp-Source: ABdhPJzBEb8NZEp1JXyXLkBIi5yab/i2qP8AESQsaijSHQ7/VIQ1dyXl1p0L8s8SXwWePm34TOgUxA== X-Received: by 2002:a17:90a:a613:: with SMTP id c19mr2002673pjq.117.1618465371459; Wed, 14 Apr 2021 22:42:51 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Subject: [PATCH v2 1/4] target/ppc: Fix POWER9 radix guest HV interrupt AIL behaviour Date: Thu, 15 Apr 2021 15:42:24 +1000 Message-Id: <20210415054227.1793812-2-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210415054227.1793812-1-npiggin@gmail.com> References: <20210415054227.1793812-1-npiggin@gmail.com> 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::102f; envelope-from=npiggin@gmail.com; helo=mail-pj1-x102f.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, FREEMAIL_FROM=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fabiano Rosas , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-devel@nongnu.org, Nicholas Piggin , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" ISA v3.0 radix guest execution has a quirk in AIL behaviour such that the LPCR[AIL] value can apply to hypervisor interrupts. This affects machines that emulate HV=3D1 mode (i.e., powernv9). Signed-off-by: Nicholas Piggin Reviewed-by: Fabiano Rosas --- target/ppc/excp_helper.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 85de7e6c90..b8881c0f85 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -791,14 +791,23 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int = excp_model, int excp) #endif =20 /* - * AIL only works if there is no HV transition and we are running - * with translations enabled + * AIL only works if MSR[IR] and MSR[DR] are both enabled. */ - if (!((msr >> MSR_IR) & 1) || !((msr >> MSR_DR) & 1) || - ((new_msr & MSR_HVB) && !(msr & MSR_HVB))) { + if (!((msr >> MSR_IR) & 1) || !((msr >> MSR_DR) & 1)) { ail =3D 0; } =20 + /* + * AIL does not work if there is a MSR[HV] 0->1 transition and the + * partition is in HPT mode. For radix guests, such interrupts are + * allowed to be delivered to the hypervisor in ail mode. + */ + if ((new_msr & MSR_HVB) && !(msr & MSR_HVB)) { + if (!(env->spr[SPR_LPCR] & LPCR_HR)) { + ail =3D 0; + } + } + vector =3D env->excp_vectors[excp]; if (vector =3D=3D (target_ulong)-1ULL) { cpu_abort(cs, "Raised an exception without defined vector %d\n", --=20 2.23.0 From nobody Sat May 18 21:15:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1618465465; cv=none; d=zohomail.com; s=zohoarc; b=CNJlL/9dcQ5ztYirDl67HPX0KA1q1WLumIa7SlTHOXIsy+2fswRWKo1aHci6tu8h3+KHodwXsu8rAvho3j96ewx/9fvzdNXU9RA+aPxTieV5wUJCoFw2kTu/XbW0c4H7FaFhn3bZyDxIb2q0AFgYpGXupqerhEGsHrF+IbBM4io= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618465465; 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=GED0ZF8HtdzmoND4pHbVLrTUNvZgoh07XD60ebAVcAY=; b=kovMiYe94rDdFH9OmBZqHtxP8ePAnLTPzB7mulkgmKTXv7CWl+/NRzVBf38aWLOMV1uHkL61CIPOs1En6gIfKYhUU7PP+QQeIGfXqyZMK3WGkpa6834KkV+b3aIMRryPzDQ1yZpM7IkibRytncOtcAx1iAnkmcLbHpY5YbBTikM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1618465465224596.7776730358586; Wed, 14 Apr 2021 22:44:25 -0700 (PDT) Received: from localhost ([::1]:56614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lWung-0002T6-3o for importer@patchew.org; Thu, 15 Apr 2021 01:44:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lWumH-0000lW-Nb; Thu, 15 Apr 2021 01:42:57 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:43676) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lWumG-0007JR-4k; Thu, 15 Apr 2021 01:42:57 -0400 Received: by mail-pj1-x102e.google.com with SMTP id x21-20020a17090a5315b029012c4a622e4aso12048575pjh.2; Wed, 14 Apr 2021 22:42:55 -0700 (PDT) Received: from bobo.ibm.com (193-116-90-211.tpgi.com.au. [193.116.90.211]) by smtp.gmail.com with ESMTPSA id c5sm946151pfp.183.2021.04.14.22.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Apr 2021 22:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GED0ZF8HtdzmoND4pHbVLrTUNvZgoh07XD60ebAVcAY=; b=K/J6xKJ+Yaj2vo7UspnjHvP1/axJXx07+Pu7sx8AdhJIu89G7BoycDOALJl/O0xXgz ac2OO5HxLculSQZozhC9f4mmyGkoQKQorebgKBPbO6Liw6cL+1W2XZMCiP7AcSHzZ4JV BZiI8InsmPvkoQGWAmOfm+lqtkFIOzoXFW8z9zXOIRiRgd9YBiYB3li+yBnxnsskIoAt EhxHaQGH636g9YwTL4+fk0UCuojZtaQCRlC59RR5n+ftvX+A5pZR0d2XEzsK1NGzbbZ4 hYcG4e73LT2P7vlQoXwp3kB2HU7WAxGjZ+liEJ9mDNnUk10w7GEK51NZetGF/iCdmSYx 58hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GED0ZF8HtdzmoND4pHbVLrTUNvZgoh07XD60ebAVcAY=; b=e2wndz/VoThUtwxhpM1v8/Mv3fN0yMVPm7zXt6yuzmlcX5lnHOrhMvbNs0MH5LS6Wg O5nxjXLETj8W5wzv27kL29CLeGk+/4L77gFyl6c89Qiai7ROY/RGpGYblAOB+dsiD4KE jgIV1rFA3lYoWerS9+u98iy0P1AO4ugLzrZynSmzCZ2uRrhThtJV8hhSqR9pPTWFnytS EsS0NEEZyOcntAvW3kyUkahPGRa0DX/HbXidJyShqYCrcmCXwajtrndHQc2/ob+xCXWi fKyqjDD/H/UG50Y4XavhHO2BglWMEUsdU8CYlQlWAIItkRi5U2sYGpwGctQ+5OYNOv5f MNzw== X-Gm-Message-State: AOAM531jrqyeIzuYLil9h/tlfPLSBsU2IHmGgJUOOjdVqv6RSs9BV1hx oBr7K4xFnJWphUuLahDV4MgRZVFw8Ug= X-Google-Smtp-Source: ABdhPJy0M9MYDW7ZRzrc1f7XHtXlrDVVJjbAqAALg803RnlOG1ZA8ilevHO+NfiSU1sUVtLdyThTyw== X-Received: by 2002:a17:90b:2314:: with SMTP id mt20mr1975782pjb.99.1618465374580; Wed, 14 Apr 2021 22:42:54 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Subject: [PATCH v2 2/4] target/ppc: POWER10 supports scv Date: Thu, 15 Apr 2021 15:42:25 +1000 Message-Id: <20210415054227.1793812-3-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210415054227.1793812-1-npiggin@gmail.com> References: <20210415054227.1793812-1-npiggin@gmail.com> 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::102e; envelope-from=npiggin@gmail.com; helo=mail-pj1-x102e.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, FREEMAIL_FROM=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fabiano Rosas , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-devel@nongnu.org, Nicholas Piggin , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This must have slipped through the cracks between adding POWER10 support and scv support. Signed-off-by: Nicholas Piggin Reviewed-by: C=C3=A9dric Le Goater --- target/ppc/translate_init.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.= inc index c03a7c4f52..70f9b9b150 100644 --- a/target/ppc/translate_init.c.inc +++ b/target/ppc/translate_init.c.inc @@ -9323,7 +9323,7 @@ POWERPC_FAMILY(POWER10)(ObjectClass *oc, void *data) pcc->flags =3D POWERPC_FLAG_VRE | POWERPC_FLAG_SE | POWERPC_FLAG_BE | POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR | - POWERPC_FLAG_VSX | POWERPC_FLAG_TM; + POWERPC_FLAG_VSX | POWERPC_FLAG_TM | POWERPC_FLAG_SCV; pcc->l1_dcache_size =3D 0x8000; pcc->l1_icache_size =3D 0x8000; pcc->interrupts_big_endian =3D ppc_cpu_interrupts_big_endian_lpcr; --=20 2.23.0 From nobody Sat May 18 21:15:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1618465579; cv=none; d=zohomail.com; s=zohoarc; b=b8CBdvWBJ36/MMJwS+hADlIxX5jYUMIcG1akfWQz3+vNYCKkNjC1oWLG3tJ2xe/hfJaL8oKbgzkzcp5QE6NHha3W3/bamu4+QuwzDR4ZSF4qsms8dCMYtzpZUA1eR0yxPp/klxi20GVSwa+7UaI6jZNjwE7DNDuOlaJeDnVMLNs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618465579; h=Content-Type: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=V9IONQCqvyDt3g22Ly9P8OHEt4nVCDIntosmo1Rhgbg=; b=Hu0lwpR3H0LSgVYDap/jng1JxnHtd6wiMykgVVovK3Jr/k6KzP4Qubs5x+DjrkyY4SYqwTo4sTpGEWBojCQbaJzB/m644p1O8MJ+EbplNWeljtqqm0rNEECIEloI1cpiCUwfRJMlzVyKb6zJTMk4GTZSGYOMffIniJoYwhp/SPU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1618465579272725.6131636840737; Wed, 14 Apr 2021 22:46:19 -0700 (PDT) Received: from localhost ([::1]:34656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lWupW-00054w-7a for importer@patchew.org; Thu, 15 Apr 2021 01:46:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lWumM-0000v2-Ee; Thu, 15 Apr 2021 01:43:02 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:44819) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lWumK-0007LR-3a; Thu, 15 Apr 2021 01:43:02 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d8so11422786plh.11; Wed, 14 Apr 2021 22:42:59 -0700 (PDT) Received: from bobo.ibm.com (193-116-90-211.tpgi.com.au. [193.116.90.211]) by smtp.gmail.com with ESMTPSA id c5sm946151pfp.183.2021.04.14.22.42.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Apr 2021 22:42:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V9IONQCqvyDt3g22Ly9P8OHEt4nVCDIntosmo1Rhgbg=; b=rKOyDxYbktgCl/iubXI967J23KTdV14F9ey6tyEsrX8foVK8OFpu5V7807yf7yqajq jEa7ufQ1pkD6r3Ib6tC29EZUmRbUIYzOa68JDNI9P3coBK5j7mhG5YUWmTqpuX8ACH37 2ZBJiwGZSYFbInflkq49q6r9UB+jrFf6W6mRh5AWXP3wZVrUM3Hs9EN9RUt1mslE6Ocl UWckdgG9f3pbiNPNktqKRjWR3oJ6euX9WdjPAGz5DWUQsl8kXkn3aqa3rSv1Gjgn6jU+ WHbcOS+LdhhtcJYEC2em83auZxC35U8LyOihg/MU9oyxJMpYs1xwZtWPtTNNB3UwxVrN JcsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=V9IONQCqvyDt3g22Ly9P8OHEt4nVCDIntosmo1Rhgbg=; b=dZT6DWc9zSye09EdcRmzXark3DYEDjjWTLWjw7AvKuSZuoXXcY3Cc2c4jKh9SLyCba CovVP78l+hulxDM5eZEwW66wxhGiWeubjzfis/SyWSXRwSwXLnwrQhvS/apemMZe+dAL NgQgNjad7/nxFoqRqG+kFMFDCLAFUOdjVZR1QGPhNM3hYBlwML63WPD9VuOcvVPAtPNh /j8l0oGc/sJ0Yu/zppNm11xubUDEhi37f6SOSJ7vKbfUlW9IDemMXi1EEPa72EDIaoOt 90/l3ES7FFQUT1fY1tztsHeLVSiR6VQE0LrkJDp5sdWpEPkJGvVcJnHJQXaO3RpPNPU0 ojdQ== X-Gm-Message-State: AOAM5315IQ6pz1Hm2FQZv0ay9TaZ9IE5sBqAUn83h0f/A17gJMa2RQ4K lACNfzTE5iEHCOsIOrDMn3CjCvjZYWo= X-Google-Smtp-Source: ABdhPJwweqmh5hZruLo19s8A7By8cgKCuRImwjQVm8/m77KI6RflxBnwKCXWXoO+C7thAMu1IGjcbg== X-Received: by 2002:a17:90a:650c:: with SMTP id i12mr2029069pjj.204.1618465378120; Wed, 14 Apr 2021 22:42:58 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Subject: [PATCH v2 3/4] target/ppc: Rework AIL logic in interrupt delivery Date: Thu, 15 Apr 2021 15:42:26 +1000 Message-Id: <20210415054227.1793812-4-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210415054227.1793812-1-npiggin@gmail.com> References: <20210415054227.1793812-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::62e; envelope-from=npiggin@gmail.com; helo=mail-pl1-x62e.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, FREEMAIL_FROM=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fabiano Rosas , qemu-devel@nongnu.org, Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The AIL logic is becoming unmanageable spread all over powerpc_excp(), and it is slated to get even worse with POWER10 support. Move it all to a new helper function. Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater Signed-off-by: Nicholas Piggin --- hw/ppc/spapr_hcall.c | 3 +- target/ppc/cpu.h | 8 -- target/ppc/excp_helper.c | 159 ++++++++++++++++++++------------ target/ppc/translate_init.c.inc | 2 +- 4 files changed, 102 insertions(+), 70 deletions(-) diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 7b5cd3553c..2fbe04a689 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1395,7 +1395,8 @@ static target_ulong h_set_mode_resource_addr_trans_mo= de(PowerPCCPU *cpu, return H_P4; } =20 - if (mflags =3D=3D AIL_RESERVED) { + if (mflags =3D=3D 1) { + /* AIL=3D1 is reserved */ return H_UNSUPPORTED_FLAG; } =20 diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index e73416da68..5200a16d23 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -2375,14 +2375,6 @@ enum { HMER_XSCOM_STATUS_MASK =3D PPC_BITMASK(21, 23), }; =20 -/* Alternate Interrupt Location (AIL) */ -enum { - AIL_NONE =3D 0, - AIL_RESERVED =3D 1, - AIL_0001_8000 =3D 2, - AIL_C000_0000_0000_4000 =3D 3, -}; - /*************************************************************************= ****/ =20 #define is_isa300(ctx) (!!(ctx->insns_flags2 & PPC2_ISA300)) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index b8881c0f85..964a58cfdc 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -136,25 +136,105 @@ static int powerpc_reset_wakeup(CPUState *cs, CPUPPC= State *env, int excp, return POWERPC_EXCP_RESET; } =20 -static uint64_t ppc_excp_vector_offset(CPUState *cs, int ail) +/* + * AIL - Alternate Interrupt Location, a mode that allows interrupts to be + * taken with the MMU on, and which uses an alternate location (e.g., so t= he + * kernel/hv can map the vectors there with an effective address). + * + * An interrupt is considered to be taken "with AIL" or "AIL applies" if t= hey + * are delivered in this way. AIL requires the LPCR to be set to enable th= is + * mode, and then a number of conditions have to be true for AIL to apply. + * + * First of all, SRESET, MCE, and HMI are always delivered without AIL, be= cause + * they specifically want to be in real mode (e.g., the MCE might be signa= ling + * a SLB multi-hit which requires SLB flush before the MMU can be enabled). + * + * After that, behaviour depends on the current MSR[IR], MSR[DR], MSR[HV], + * whether or not the interrupt changes MSR[HV] from 0 to 1, and the curre= nt + * radix mode (LPCR[HR]). + * + * POWER8, POWER9 with LPCR[HR]=3D0 + * | LPCR[AIL] | MSR[IR||DR] | MSR[HV] | new MSR[HV] | AIL | + * +-----------+-------------+---------+-------------+-----+ + * | a | 00/01/10 | x | x | 0 | + * | a | 11 | 0 | 1 | 0 | + * | a | 11 | 1 | 1 | a | + * | a | 11 | 0 | 0 | a | + * +-------------------------------------------------------+ + * + * POWER9 with LPCR[HR]=3D1 + * | LPCR[AIL] | MSR[IR||DR] | MSR[HV] | new MSR[HV] | AIL | + * +-----------+-------------+---------+-------------+-----+ + * | a | 00/01/10 | x | x | 0 | + * | a | 11 | x | x | a | + * +-------------------------------------------------------+ + * + * The difference with POWER9 being that MSR[HV] 0->1 interrupts can be se= nt to + * the hypervisor in AIL mode if the guest is radix. + */ +static inline void ppc_excp_apply_ail(PowerPCCPU *cpu, int excp_model, int= excp, + target_ulong msr, + target_ulong *new_msr, + target_ulong *vector) { - uint64_t offset =3D 0; +#if defined(TARGET_PPC64) + CPUPPCState *env =3D &cpu->env; + bool mmu_all_on =3D ((msr >> MSR_IR) & 1) && ((msr >> MSR_DR) & 1); + bool hv_escalation =3D !(msr & MSR_HVB) && (*new_msr & MSR_HVB); + int ail =3D 0; + + if (excp =3D=3D POWERPC_EXCP_MCHECK || + excp =3D=3D POWERPC_EXCP_RESET || + excp =3D=3D POWERPC_EXCP_HV_MAINT) { + /* SRESET, MCE, HMI never apply AIL */ + return; + } =20 - switch (ail) { - case AIL_NONE: - break; - case AIL_0001_8000: - offset =3D 0x18000; - break; - case AIL_C000_0000_0000_4000: - offset =3D 0xc000000000004000ull; - break; - default: - cpu_abort(cs, "Invalid AIL combination %d\n", ail); - break; + if (excp_model =3D=3D POWERPC_EXCP_POWER8 || + excp_model =3D=3D POWERPC_EXCP_POWER9) { + if (!mmu_all_on) { + /* AIL only works if MSR[IR] and MSR[DR] are both enabled. */ + return; + } + if (hv_escalation && !(env->spr[SPR_LPCR] & LPCR_HR)) { + /* + * AIL does not work if there is a MSR[HV] 0->1 transition and= the + * partition is in HPT mode. For radix guests, such interrupts= are + * allowed to be delivered to the hypervisor in ail mode. + */ + return; + } + + ail =3D (env->spr[SPR_LPCR] & LPCR_AIL) >> LPCR_AIL_SHIFT; + if (ail !=3D 2 && ail !=3D 3) { + /* AIL=3D1 is reserved */ + return; + } + } else { + /* Other processors do not support AIL */ + return; } =20 - return offset; + /* + * AIL applies, so the new MSR gets IR and DR set, and an offset appli= ed + * to the new IP. + */ + *new_msr |=3D (1 << MSR_IR) | (1 << MSR_DR); + + if (excp !=3D POWERPC_EXCP_SYSCALL_VECTORED) { + if (ail =3D=3D 2) { + *vector |=3D 0x0000000000018000ull; + } else if (ail =3D=3D 3) { + *vector |=3D 0xc000000000004000ull; + } + } else { + /* scv AIL is a little different */ + if (ail =3D=3D 3) { + *vector &=3D ~0x0000000000017000ull; /* Un-apply the base offs= et */ + *vector |=3D 0xc000000000003000ull; /* Apply scv's AIL=3D3 off= set */ + } + } +#endif } =20 static inline void powerpc_set_excp_state(PowerPCCPU *cpu, @@ -197,7 +277,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int ex= cp_model, int excp) CPUState *cs =3D CPU(cpu); CPUPPCState *env =3D &cpu->env; target_ulong msr, new_msr, vector; - int srr0, srr1, asrr0, asrr1, lev =3D -1, ail; + int srr0, srr1, asrr0, asrr1, lev =3D -1; bool lpes0; =20 qemu_log_mask(CPU_LOG_INT, "Raise exception at " TARGET_FMT_lx @@ -238,25 +318,16 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int = excp_model, int excp) * * On anything else, we behave as if LPES0 is 1 * (externals don't alter MSR:HV) - * - * AIL is initialized here but can be cleared by - * selected exceptions */ #if defined(TARGET_PPC64) if (excp_model =3D=3D POWERPC_EXCP_POWER7 || excp_model =3D=3D POWERPC_EXCP_POWER8 || excp_model =3D=3D POWERPC_EXCP_POWER9) { lpes0 =3D !!(env->spr[SPR_LPCR] & LPCR_LPES0); - if (excp_model !=3D POWERPC_EXCP_POWER7) { - ail =3D (env->spr[SPR_LPCR] & LPCR_AIL) >> LPCR_AIL_SHIFT; - } else { - ail =3D 0; - } } else #endif /* defined(TARGET_PPC64) */ { lpes0 =3D true; - ail =3D 0; } =20 /* @@ -315,7 +386,6 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int ex= cp_model, int excp) */ new_msr |=3D (target_ulong)MSR_HVB; } - ail =3D 0; =20 /* machine check exceptions don't have ME set */ new_msr &=3D ~((target_ulong)1 << MSR_ME); @@ -519,7 +589,6 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int ex= cp_model, int excp) "exception %d with no HV support\n", excp); } } - ail =3D 0; break; case POWERPC_EXCP_DSEG: /* Data segment exception = */ case POWERPC_EXCP_ISEG: /* Instruction segment exception = */ @@ -790,24 +859,6 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int e= xcp_model, int excp) } #endif =20 - /* - * AIL only works if MSR[IR] and MSR[DR] are both enabled. - */ - if (!((msr >> MSR_IR) & 1) || !((msr >> MSR_DR) & 1)) { - ail =3D 0; - } - - /* - * AIL does not work if there is a MSR[HV] 0->1 transition and the - * partition is in HPT mode. For radix guests, such interrupts are - * allowed to be delivered to the hypervisor in ail mode. - */ - if ((new_msr & MSR_HVB) && !(msr & MSR_HVB)) { - if (!(env->spr[SPR_LPCR] & LPCR_HR)) { - ail =3D 0; - } - } - vector =3D env->excp_vectors[excp]; if (vector =3D=3D (target_ulong)-1ULL) { cpu_abort(cs, "Raised an exception without defined vector %d\n", @@ -848,23 +899,8 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int e= xcp_model, int excp) /* Save MSR */ env->spr[srr1] =3D msr; =20 - /* Handle AIL */ - if (ail) { - new_msr |=3D (1 << MSR_IR) | (1 << MSR_DR); - vector |=3D ppc_excp_vector_offset(cs, ail); - } - #if defined(TARGET_PPC64) } else { - /* scv AIL is a little different */ - if (ail) { - new_msr |=3D (1 << MSR_IR) | (1 << MSR_DR); - } - if (ail =3D=3D AIL_C000_0000_0000_4000) { - vector |=3D 0xc000000000003000ull; - } else { - vector |=3D 0x0000000000017000ull; - } vector +=3D lev * 0x20; =20 env->lr =3D env->nip; @@ -872,6 +908,9 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int ex= cp_model, int excp) #endif } =20 + /* This can update new_msr and vector if AIL applies */ + ppc_excp_apply_ail(cpu, excp_model, excp, msr, &new_msr, &vector); + powerpc_set_excp_state(cpu, vector, new_msr); } =20 diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.= inc index 70f9b9b150..a82d9ed647 100644 --- a/target/ppc/translate_init.c.inc +++ b/target/ppc/translate_init.c.inc @@ -3457,7 +3457,7 @@ static void init_excp_POWER9(CPUPPCState *env) =20 #if !defined(CONFIG_USER_ONLY) env->excp_vectors[POWERPC_EXCP_HVIRT] =3D 0x00000EA0; - env->excp_vectors[POWERPC_EXCP_SYSCALL_VECTORED] =3D 0x00000000; + env->excp_vectors[POWERPC_EXCP_SYSCALL_VECTORED] =3D 0x00017000; #endif } =20 --=20 2.23.0 From nobody Sat May 18 21:15:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1618465514; cv=none; d=zohomail.com; s=zohoarc; b=P5csLlGSvjpWkBTJXHnnFUbzUzpgU9fjnIocxSVLVs/njn3NwtyI5g1ieIDNR2aLcesomuC+AGQ0TZO2jeXxbrH5XdNU8odD7E0azpjMrHi1hO0mytmJksrCNiJnREoSWk6VKvhItI7ZbAPEEyGYXFlJszHGiGxX8W8o7goAFLM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618465514; h=Content-Type: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=M26yWQc4q67700097W0NkPStXmiNiZzPY2I6R9bkgkw=; b=PWJ/KJrG4sXOqP/kigH2cZB7bPNafn6xvdQ1XCFwqQRFOw6nhihlF+cWcRTGp91l/uGXiRyqqwpMxcCP/vGjw+Ieitad/6EfC6B79oa7AB6jSgfYMOlCT6hgpVTxLdDKrx7+FOlEC42IXydrAuJ11gVm84QzjKGByZMQ1bwYZH4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1618465514700259.6372040325359; Wed, 14 Apr 2021 22:45:14 -0700 (PDT) Received: from localhost ([::1]:59126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lWuoT-0003Si-9S for importer@patchew.org; Thu, 15 Apr 2021 01:45:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lWumT-00017R-Ko; Thu, 15 Apr 2021 01:43:09 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:37383) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lWumO-0007NP-Kr; Thu, 15 Apr 2021 01:43:09 -0400 Received: by mail-pf1-x429.google.com with SMTP id o123so15322866pfb.4; Wed, 14 Apr 2021 22:43:02 -0700 (PDT) Received: from bobo.ibm.com (193-116-90-211.tpgi.com.au. [193.116.90.211]) by smtp.gmail.com with ESMTPSA id c5sm946151pfp.183.2021.04.14.22.42.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Apr 2021 22:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=M26yWQc4q67700097W0NkPStXmiNiZzPY2I6R9bkgkw=; b=ZC7+9Aqk/VW/POjP85tStkfhZ5AD4xxM1cPS4d5ez7o2iEvRgSrZc4LgfR6YB35d3k FaOUh7wV4RZJI6UeTPGIhf5wF1VRzYmr2c6qwLSUw7aDX/86fFaZa7aI9jHNJvEryFds ernCLvivglWL767ih/kxxzHRHOEltIQtJ9wNRPtjnnJSCN+NlAzHPo64wkMiVyaNNhfh 1NI2/0jgqU5M05MCO/pSMX5eiTHFnC38hf55muxRrHpMcl/Jqv9tDWirxTinH/MYJM2+ E9jMXMlxWF37azNVwk0OlNOOx59RAMldAMijSzpDNq9BRSQuTLd8R7B8mvJompQLQdOw B6vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=M26yWQc4q67700097W0NkPStXmiNiZzPY2I6R9bkgkw=; b=qNQ0/rjWi7dizk5uifaAxZiUVkWLfqirNkL+uQVv9sgbeVT00NHf2M9alsDA9EhsAn QOvHVVqthlL1ao+GWX/2ioGdAI2psgxmPwHwHUddhhm87V58ap0wNyXExIMsniOBsy3y x3jAMbEE/L4WG0+hwjFgu1wLR9vGY7nYZ5Fw2B+BM55euUANP/eebJW7jnnriilhylho 6HHumkCd8+ityF/7J/HImCEL75Mmvq6apD0oxqZ+e4MreFQ/UMYERuQ/Fz+krguBEPQ9 1AmyLCM0U1sh7wTq4ZFZaZvJQxIeXAiEUXkdjAdWteqmOylOM8xbOSitA4F1STKhaZuZ Rq8A== X-Gm-Message-State: AOAM5300YVPnUDuXLwl8EKgXnJXv6zFZyDPXWn6eQEDI/eB4D5DU7mpj b5LARM6IqLaRPhsnqyD7v82jcfTcpfM= X-Google-Smtp-Source: ABdhPJwI21v6bwL2zfl44bnSwBm9C13gxRmgaH+dAreW5ir4t0NUl1NxnFM/CPUNM+eC4FVjFUc28g== X-Received: by 2002:a62:7793:0:b029:23d:f8f4:73c9 with SMTP id s141-20020a6277930000b029023df8f473c9mr1809050pfc.61.1618465381607; Wed, 14 Apr 2021 22:43:01 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Subject: [PATCH v2 4/4] target/ppc: Add POWER10 exception model Date: Thu, 15 Apr 2021 15:42:27 +1000 Message-Id: <20210415054227.1793812-5-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210415054227.1793812-1-npiggin@gmail.com> References: <20210415054227.1793812-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::429; envelope-from=npiggin@gmail.com; helo=mail-pf1-x429.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, FREEMAIL_FROM=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fabiano Rosas , qemu-devel@nongnu.org, Nicholas Piggin , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) POWER10 adds a new bit that modifies interrupt behaviour, LPCR[HAIL], and it removes support for the LPCR[AIL]=3D0b10 mode. Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater Signed-off-by: Nicholas Piggin --- hw/ppc/spapr_hcall.c | 7 ++++- target/ppc/cpu-qom.h | 2 ++ target/ppc/cpu.h | 5 ++-- target/ppc/excp_helper.c | 51 +++++++++++++++++++++++++++++++-- target/ppc/translate.c | 3 +- target/ppc/translate_init.c.inc | 2 +- 6 files changed, 62 insertions(+), 8 deletions(-) diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 2fbe04a689..6802cd4dc8 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1396,7 +1396,12 @@ static target_ulong h_set_mode_resource_addr_trans_m= ode(PowerPCCPU *cpu, } =20 if (mflags =3D=3D 1) { - /* AIL=3D1 is reserved */ + /* AIL=3D1 is reserved in POWER8/POWER9 */ + return H_UNSUPPORTED_FLAG; + } + + if (mflags =3D=3D 2 && (pcc->insns_flags2 & PPC2_ISA310)) { + /* AIL=3D2 is also reserved in POWER10 (ISA v3.1) */ return H_UNSUPPORTED_FLAG; } =20 diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index 118baf8d41..06b6571bc9 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -116,6 +116,8 @@ enum powerpc_excp_t { POWERPC_EXCP_POWER8, /* POWER9 exception model */ POWERPC_EXCP_POWER9, + /* POWER10 exception model */ + POWERPC_EXCP_POWER10, }; =20 /*************************************************************************= ****/ diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 5200a16d23..9d35cdfa92 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -354,10 +354,11 @@ typedef struct ppc_v3_pate_t { #define LPCR_PECE_U_SHIFT (63 - 19) #define LPCR_PECE_U_MASK (0x7ull << LPCR_PECE_U_SHIFT) #define LPCR_HVEE PPC_BIT(17) /* Hypervisor Virt Exit Enable */ -#define LPCR_RMLS_SHIFT (63 - 37) +#define LPCR_RMLS_SHIFT (63 - 37) /* RMLS (removed in ISA v3.0) */ #define LPCR_RMLS (0xfull << LPCR_RMLS_SHIFT) +#define LPCR_HAIL PPC_BIT(37) /* ISA v3.1 HV AIL=3D3 equivalent */ #define LPCR_ILE PPC_BIT(38) -#define LPCR_AIL_SHIFT (63 - 40) /* Alternate interrupt location */ +#define LPCR_AIL_SHIFT (63 - 40) /* Alternate interrupt location */ #define LPCR_AIL (3ull << LPCR_AIL_SHIFT) #define LPCR_UPRT PPC_BIT(41) /* Use Process Table */ #define LPCR_EVIRT PPC_BIT(42) /* Enhanced Virtualisation */ diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 964a58cfdc..38a1482519 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -170,7 +170,27 @@ static int powerpc_reset_wakeup(CPUState *cs, CPUPPCSt= ate *env, int excp, * +-------------------------------------------------------+ * * The difference with POWER9 being that MSR[HV] 0->1 interrupts can be se= nt to - * the hypervisor in AIL mode if the guest is radix. + * the hypervisor in AIL mode if the guest is radix. This is good for + * performance but allows the guest to influence the AIL of hypervisor + * interrupts using its MSR, and also the hypervisor must disallow guest + * interrupts (MSR[HV] 0->0) from using AIL if the hypervisor does not wan= t to + * use AIL for its MSR[HV] 0->1 interrupts. + * + * POWER10 addresses those issues with a new LPCR[HAIL] bit that is applie= d to + * interrupts that begin execution with MSR[HV]=3D1 (so both MSR[HV] 0->1 = and + * MSR[HV] 1->1). + * + * HAIL=3D1 is equivalent to AIL=3D3, for interrupts delivered with MSR[HV= ]=3D1. + * + * POWER10 behaviour is + * | LPCR[AIL] | LPCR[HAIL] | MSR[IR||DR] | MSR[HV] | new MSR[HV] | AIL | + * +-----------+------------+-------------+---------+-------------+-----+ + * | a | h | 00/01/10 | 0 | 0 | 0 | + * | a | h | 11 | 0 | 0 | a | + * | a | h | x | 0 | 1 | h | + * | a | h | 00/01/10 | 1 | 1 | 0 | + * | a | h | 11 | 1 | 1 | h | + * +--------------------------------------------------------------------+ */ static inline void ppc_excp_apply_ail(PowerPCCPU *cpu, int excp_model, int= excp, target_ulong msr, @@ -210,6 +230,29 @@ static inline void ppc_excp_apply_ail(PowerPCCPU *cpu,= int excp_model, int excp, /* AIL=3D1 is reserved */ return; } + + } else if (excp_model =3D=3D POWERPC_EXCP_POWER10) { + if (!mmu_all_on && !hv_escalation) { + /* + * AIL works for HV interrupts even with guest MSR[IR/DR] disa= bled. + * Guest->guest and HV->HV interrupts do require MMU on. + */ + return; + } + + if (*new_msr & MSR_HVB) { + if (!(env->spr[SPR_LPCR] & LPCR_HAIL)) { + /* HV interrupts depend on LPCR[HAIL] */ + return; + } + ail =3D 3; /* HAIL=3D1 gives AIL=3D3 behaviour for HV interrup= ts */ + } else { + ail =3D (env->spr[SPR_LPCR] & LPCR_AIL) >> LPCR_AIL_SHIFT; + } + if (ail !=3D 3) { + /* AIL=3D1 and AIL=3D2 are reserved */ + return; + } } else { /* Other processors do not support AIL */ return; @@ -322,7 +365,8 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int ex= cp_model, int excp) #if defined(TARGET_PPC64) if (excp_model =3D=3D POWERPC_EXCP_POWER7 || excp_model =3D=3D POWERPC_EXCP_POWER8 || - excp_model =3D=3D POWERPC_EXCP_POWER9) { + excp_model =3D=3D POWERPC_EXCP_POWER9 || + excp_model =3D=3D POWERPC_EXCP_POWER10) { lpes0 =3D !!(env->spr[SPR_LPCR] & LPCR_LPES0); } else #endif /* defined(TARGET_PPC64) */ @@ -842,7 +886,8 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int ex= cp_model, int excp) } else if (env->spr[SPR_LPCR] & LPCR_ILE) { new_msr |=3D (target_ulong)1 << MSR_LE; } - } else if (excp_model =3D=3D POWERPC_EXCP_POWER9) { + } else if (excp_model =3D=3D POWERPC_EXCP_POWER9 || + excp_model =3D=3D POWERPC_EXCP_POWER10) { if (new_msr & MSR_HVB) { if (env->spr[SPR_HID0] & HID0_POWER9_HILE) { new_msr |=3D (target_ulong)1 << MSR_LE; diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 0984ce637b..e9ed001229 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7731,7 +7731,8 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, int fl= ags) #if defined(TARGET_PPC64) if (env->excp_model =3D=3D POWERPC_EXCP_POWER7 || env->excp_model =3D=3D POWERPC_EXCP_POWER8 || - env->excp_model =3D=3D POWERPC_EXCP_POWER9) { + env->excp_model =3D=3D POWERPC_EXCP_POWER9 || + env->excp_model =3D=3D POWERPC_EXCP_POWER10) { qemu_fprintf(f, "HSRR0 " TARGET_FMT_lx " HSRR1 " TARGET_FMT_lx "\n= ", env->spr[SPR_HSRR0], env->spr[SPR_HSRR1]); } diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.= inc index a82d9ed647..76d82cc2f6 100644 --- a/target/ppc/translate_init.c.inc +++ b/target/ppc/translate_init.c.inc @@ -9317,7 +9317,7 @@ POWERPC_FAMILY(POWER10)(ObjectClass *oc, void *data) pcc->radix_page_info =3D &POWER10_radix_page_info; pcc->lrg_decr_bits =3D 56; #endif - pcc->excp_model =3D POWERPC_EXCP_POWER9; + pcc->excp_model =3D POWERPC_EXCP_POWER10; pcc->bus_model =3D PPC_FLAGS_INPUT_POWER9; pcc->bfd_mach =3D bfd_mach_ppc64; pcc->flags =3D POWERPC_FLAG_VRE | POWERPC_FLAG_SE | --=20 2.23.0