From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Mackerras Date: Wed, 08 Mar 2023 06:33:43 +0000 Subject: [PATCH 0/3] powerpc/kvm: Enable HV KVM guests to use prefixed instructions to access emulated MMIO Message-Id: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linuxppc-dev@ozlabs.org, kvm@vger.kernel.org Cc: Michael Neuling , Nick Piggin , kvm-ppc@vger.kernel.org This series changes the powerpc KVM code so that HV KVM can fetch prefixed instructions from the guest in those situations where there is a need to emulate an instruction, which for HV KVM means emulating loads and stores to emulated MMIO devices. (Prefixed instructions were introduced with POWER10 and Power ISA v3.1, and consist of two 32-bit words, called the prefix and the suffix.) The instruction analysis code in arch/powerpc/lib/sstep.c has already been extended to handle prefixed loads and stores, so all we have to do in HV KVM is to fetch the suffix when necessary and pass it to analyse_instr(). Since PR KVM doesn't yet handle prefixed instructions, we disable PR KVM guests from using prefixed instructions (this is done using the FSCR). Paul. arch/powerpc/include/asm/kvm_host.h | 4 ++-- arch/powerpc/include/asm/kvm_ppc.h | 37 +++++++++++++++++++++++--------- arch/powerpc/include/asm/reg.h | 1 + arch/powerpc/kvm/book3s.c | 32 ++++++++++++++++++++++----- arch/powerpc/kvm/book3s_64_mmu_hv.c | 26 ++++++++++++++++------ arch/powerpc/kvm/book3s_hv.c | 24 ++++++++++++++------- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 6 +++--- arch/powerpc/kvm/book3s_paired_singles.c | 4 +++- arch/powerpc/kvm/book3s_pr.c | 22 ++++++++++--------- arch/powerpc/kvm/book3s_rmhandlers.S | 1 + arch/powerpc/kvm/booke.c | 12 +++++++---- arch/powerpc/kvm/bookehv_interrupts.S | 2 +- arch/powerpc/kvm/e500_mmu_host.c | 4 ++-- arch/powerpc/kvm/emulate.c | 8 ++++++- arch/powerpc/kvm/emulate_loadstore.c | 8 +++---- arch/powerpc/kvm/powerpc.c | 4 ++-- 16 files changed, 136 insertions(+), 59 deletions(-) From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8CF1C64EC4 for ; Wed, 8 Mar 2023 06:39:52 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4PWjNR492Pz3cf2 for ; Wed, 8 Mar 2023 17:39:51 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=vDkN/hgS; dkim-atps=neutral Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4PWjJY05X0z3c7t for ; Wed, 8 Mar 2023 17:36:28 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=vDkN/hgS; dkim-atps=neutral Received: by gandalf.ozlabs.org (Postfix) id 4PWjJS1Vqzz4xDl; Wed, 8 Mar 2023 17:36:24 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix, from userid 1003) id 4PWjJS1PRgz4xDk; Wed, 8 Mar 2023 17:36:24 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ozlabs.org; s=201707; t=1678257384; bh=xlh8AKwmpAujiBC2TZ8TY34N1ZFaVIBckKl457W8J10=; h=Date:From:To:Cc:Subject:From; b=vDkN/hgStBQKJlPuU1xJd5EiafxrU6GgJW87tN1Bsh1jcJ6eqKgHUSR/7DQPbFRRC pQUCfITFhoyjG721Ii92hmEeKoRTeBMffaasIyw6wVV7cQByRyKyv5Nr/I4EQOOA2V vjR4syd9hFNejQOPiW3oYtYqceouA4GdcsP792dvibsGZUW/HnPMDgT46A+bOpzPeR //Kh7dznGphnJN+RsuhwGpLPqtF8eC+SVSoAdnFHqIfsjfguIrscaKZZnx+7E+nRR+ dvCEjFBXqfGbhC0pJ5Z8Vj4U1+zUKkv8MGqkBAI9P22gr96bZftMh/23DpM10PBbPW uvZ69+Z8OSauA== Date: Wed, 8 Mar 2023 17:33:43 +1100 From: Paul Mackerras To: linuxppc-dev@ozlabs.org, kvm@vger.kernel.org Subject: [PATCH 0/3] powerpc/kvm: Enable HV KVM guests to use prefixed instructions to access emulated MMIO Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Neuling , kvm-ppc@vger.kernel.org, Nick Piggin Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" This series changes the powerpc KVM code so that HV KVM can fetch prefixed instructions from the guest in those situations where there is a need to emulate an instruction, which for HV KVM means emulating loads and stores to emulated MMIO devices. (Prefixed instructions were introduced with POWER10 and Power ISA v3.1, and consist of two 32-bit words, called the prefix and the suffix.) The instruction analysis code in arch/powerpc/lib/sstep.c has already been extended to handle prefixed loads and stores, so all we have to do in HV KVM is to fetch the suffix when necessary and pass it to analyse_instr(). Since PR KVM doesn't yet handle prefixed instructions, we disable PR KVM guests from using prefixed instructions (this is done using the FSCR). Paul. arch/powerpc/include/asm/kvm_host.h | 4 ++-- arch/powerpc/include/asm/kvm_ppc.h | 37 +++++++++++++++++++++++--------- arch/powerpc/include/asm/reg.h | 1 + arch/powerpc/kvm/book3s.c | 32 ++++++++++++++++++++++----- arch/powerpc/kvm/book3s_64_mmu_hv.c | 26 ++++++++++++++++------ arch/powerpc/kvm/book3s_hv.c | 24 ++++++++++++++------- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 6 +++--- arch/powerpc/kvm/book3s_paired_singles.c | 4 +++- arch/powerpc/kvm/book3s_pr.c | 22 ++++++++++--------- arch/powerpc/kvm/book3s_rmhandlers.S | 1 + arch/powerpc/kvm/booke.c | 12 +++++++---- arch/powerpc/kvm/bookehv_interrupts.S | 2 +- arch/powerpc/kvm/e500_mmu_host.c | 4 ++-- arch/powerpc/kvm/emulate.c | 8 ++++++- arch/powerpc/kvm/emulate_loadstore.c | 8 +++---- arch/powerpc/kvm/powerpc.c | 4 ++-- 16 files changed, 136 insertions(+), 59 deletions(-) From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91555C678D5 for ; Wed, 8 Mar 2023 06:36:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229900AbjCHGgc (ORCPT ); Wed, 8 Mar 2023 01:36:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229887AbjCHGga (ORCPT ); Wed, 8 Mar 2023 01:36:30 -0500 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C3969FBCD; Tue, 7 Mar 2023 22:36:29 -0800 (PST) Received: by gandalf.ozlabs.org (Postfix, from userid 1003) id 4PWjJS1PRgz4xDk; Wed, 8 Mar 2023 17:36:24 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ozlabs.org; s=201707; t=1678257384; bh=xlh8AKwmpAujiBC2TZ8TY34N1ZFaVIBckKl457W8J10=; h=Date:From:To:Cc:Subject:From; b=vDkN/hgStBQKJlPuU1xJd5EiafxrU6GgJW87tN1Bsh1jcJ6eqKgHUSR/7DQPbFRRC pQUCfITFhoyjG721Ii92hmEeKoRTeBMffaasIyw6wVV7cQByRyKyv5Nr/I4EQOOA2V vjR4syd9hFNejQOPiW3oYtYqceouA4GdcsP792dvibsGZUW/HnPMDgT46A+bOpzPeR //Kh7dznGphnJN+RsuhwGpLPqtF8eC+SVSoAdnFHqIfsjfguIrscaKZZnx+7E+nRR+ dvCEjFBXqfGbhC0pJ5Z8Vj4U1+zUKkv8MGqkBAI9P22gr96bZftMh/23DpM10PBbPW uvZ69+Z8OSauA== Date: Wed, 8 Mar 2023 17:33:43 +1100 From: Paul Mackerras To: linuxppc-dev@ozlabs.org, kvm@vger.kernel.org Cc: Michael Neuling , Nick Piggin , kvm-ppc@vger.kernel.org Subject: [PATCH 0/3] powerpc/kvm: Enable HV KVM guests to use prefixed instructions to access emulated MMIO Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This series changes the powerpc KVM code so that HV KVM can fetch prefixed instructions from the guest in those situations where there is a need to emulate an instruction, which for HV KVM means emulating loads and stores to emulated MMIO devices. (Prefixed instructions were introduced with POWER10 and Power ISA v3.1, and consist of two 32-bit words, called the prefix and the suffix.) The instruction analysis code in arch/powerpc/lib/sstep.c has already been extended to handle prefixed loads and stores, so all we have to do in HV KVM is to fetch the suffix when necessary and pass it to analyse_instr(). Since PR KVM doesn't yet handle prefixed instructions, we disable PR KVM guests from using prefixed instructions (this is done using the FSCR). Paul. arch/powerpc/include/asm/kvm_host.h | 4 ++-- arch/powerpc/include/asm/kvm_ppc.h | 37 +++++++++++++++++++++++--------- arch/powerpc/include/asm/reg.h | 1 + arch/powerpc/kvm/book3s.c | 32 ++++++++++++++++++++++----- arch/powerpc/kvm/book3s_64_mmu_hv.c | 26 ++++++++++++++++------ arch/powerpc/kvm/book3s_hv.c | 24 ++++++++++++++------- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 6 +++--- arch/powerpc/kvm/book3s_paired_singles.c | 4 +++- arch/powerpc/kvm/book3s_pr.c | 22 ++++++++++--------- arch/powerpc/kvm/book3s_rmhandlers.S | 1 + arch/powerpc/kvm/booke.c | 12 +++++++---- arch/powerpc/kvm/bookehv_interrupts.S | 2 +- arch/powerpc/kvm/e500_mmu_host.c | 4 ++-- arch/powerpc/kvm/emulate.c | 8 ++++++- arch/powerpc/kvm/emulate_loadstore.c | 8 +++---- arch/powerpc/kvm/powerpc.c | 4 ++-- 16 files changed, 136 insertions(+), 59 deletions(-)