From patchwork Mon May 21 05:24:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Guo X-Patchwork-Id: 917411 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40q7jB3T0vz9s0W for ; Mon, 21 May 2018 16:12:14 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="bX4+y1zH"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40q7jB1q1KzF12M for ; Mon, 21 May 2018 16:12:14 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="bX4+y1zH"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c01::242; helo=mail-pl0-x242.google.com; envelope-from=wei.guo.simon@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="bX4+y1zH"; dkim-atps=neutral Received: from mail-pl0-x242.google.com (mail-pl0-x242.google.com [IPv6:2607:f8b0:400e:c01::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40q7R96MZPzF13x for ; Mon, 21 May 2018 16:00:05 +1000 (AEST) Received: by mail-pl0-x242.google.com with SMTP id az12-v6so8141759plb.8 for ; Sun, 20 May 2018 23:00:05 -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; bh=o2WaPLkaWSCxbq3NMwSZCIkUzaKwt+omd5yhfvBBn/w=; b=bX4+y1zHsX03rC9JGlXeE64lSjDEi4K7H0u8xaEgQbXNfd+/XlRBejAXB9tP5jxdX9 Nb79PQu3r3aWnudBGfI761pX+9OKwmPN/TMyrDWhS+L3N7D/wiJ3jliJYvt/y7ixOXEb EzW5MM/GDHY1ecQyPXr0yvEQbWqRHGG7eN7babRhvJjvWBcX+jPhQ62iFRIo2kOQg6cE Ytq+q1ZLBTlN0OTgl8aR9fC2Vc9VmS7PeiVuZlpUGtxKWkv5B5o/UR12FQuvNoIPOs/O pw07M/WM19GY4QEmPFj/8Plf3WG4OI5/R7nSWws6LJ4EzQjDiSuORr/Q32Kcbo9znHo1 RJCA== 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; bh=o2WaPLkaWSCxbq3NMwSZCIkUzaKwt+omd5yhfvBBn/w=; b=RYubeUWjKxolfJnt3SGCw9ezlPsl5Pb8OVbSTt/VooeES/khBUAwXfjTBR92FlwzTU QF3Qgf9Q4EvGVm8IVpzSmnKxbQrw2kPlaFsvRo9bockOoO8peBA6ZlircqbbTjWDMaXr bCujAo46is8Hs8d9DL4N8eGz2ESdrCz4kLZKQ1MqxreKCBhk6wVu7p45aH9qUE7uAZej 0sy4Vk7NlPbn3oA6ZVH4gJC8rawUMIetasxfKz7+Nf7u7mDHi+e9FiUXRzHfch/1Oeq4 3xlw+MHQpPhlIxTyTl/NIlO77ZIys+cVhGUI2epEhrJgKfa31S+UEvnu79HT1x9SCUpx dmtw== X-Gm-Message-State: ALKqPwclugj5yJrwddnbyc5JQSKooydZHDG+6AamYcIYY0X4PVDdrXkk pAxIa0UGn9fAZMdMgkm1ViE= X-Google-Smtp-Source: AB8JxZrjY0iKxAuOEFW2e7iCIHfJkMWXF4ZOUC3NjsCeX+/BJgC4PMEEieW7CkYT32/r4XrrxcsU/A== X-Received: by 2002:a17:902:8f94:: with SMTP id z20-v6mr19298237plo.391.1526882403580; Sun, 20 May 2018 23:00:03 -0700 (PDT) Received: from simonLocalRHEL7.cn.ibm.com ([112.73.0.89]) by smtp.gmail.com with ESMTPSA id g76-v6sm24424203pfj.102.2018.05.20.22.59.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 May 2018 23:00:02 -0700 (PDT) From: wei.guo.simon@gmail.com To: kvm-ppc@vger.kernel.org Subject: [PATCH v3 0/7] KVM: PPC: reimplement mmio emulation with analyse_instr() Date: Mon, 21 May 2018 13:24:19 +0800 Message-Id: <1526880266-11291-1-git-send-email-wei.guo.simon@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Simon Guo , linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Simon Guo We already have analyse_instr() which analyzes instructions for the instruction type, size, addtional flags, etc. What kvmppc_emulate_loadstore() did is somehow duplicated and it will be good to utilize analyse_instr() to reimplement the code. The advantage is that the code logic will be shared and more clean to be maintained. This patch series reimplement kvmppc_emulate_loadstore() for various load/store instructions. The testcase locates at: https://github.com/justdoitqd/publicFiles/blob/master/test_mmio.c - Tested at both PR/HV KVM. - Also tested with little endian host & big endian guest. Tested instruction list: lbz lbzu lbzx ld ldbrx ldu ldx lfd lfdu lfdx lfiwax lfiwzx lfs lfsu lfsx lha lhau lhax lhbrx lhz lhzu lhzx lvx lwax lwbrx lwz lwzu lwzx lxsdx lxsiwax lxsiwzx lxsspx lxvd2x lxvdsx lxvw4x stb stbu stbx std stdbrx stdu stdx stfd stfdu stfdx stfiwx stfs stfsx sth sthbrx sthu sthx stvx stw stwbrx stwu stwx stxsdx stxsiwx stxsspx stxvd2x stxvw4x lvebx stvebx lvehx stvehx lvewx stvewx V2 -> V3 changes: 1) add FPU SIGNEXT case to handle lfiwax based on comment. 2) a minor change to go label "out:" when EMULATE_DO_MMIO returned based on comment. 3) rebased to paul's kvm-ppc-next branch (3 patches was merged into that branch and so this patch set includes 7 patches only). V1 -> V2 changes: 1) correct patch split issue in v1. 2) revise some commit message/code comment per review comment 3) remove incorrect special handling for stxsiwx 4) remove mmio_update_ra related and move the RA update into kvmppc_emulate_loadstore(). 5) rework giveup_ext() which is only meaningful when not NULL. 6) rewrite VMX emulation code and cover rest VMX instructions: lvebx stvebx lvehx stvehx lvewx stvewx Simon Guo (7): KVM: PPC: add KVMPPC_VSX_COPY_WORD_LOAD_DUMP type support for mmio emulation KVM: PPC: reimplement non-SIMD LOAD/STORE instruction mmio emulation with analyse_intr() input KVM: PPC: add giveup_ext() hook for PPC KVM ops KVM: PPC: reimplement LOAD_FP/STORE_FP instruction mmio emulation with analyse_intr() input KVM: PPC: reimplements LOAD_VSX/STORE_VSX instruction mmio emulation with analyse_intr() input KVM: PPC: expand mmio_vsx_copy_type to mmio_copy_type to cover VMX load/store elem types KVM: PPC: reimplements LOAD_VMX/STORE_VMX instruction mmio emulation with analyse_intr() input arch/powerpc/include/asm/kvm_host.h | 11 +- arch/powerpc/include/asm/kvm_ppc.h | 17 +- arch/powerpc/kvm/book3s.c | 4 +- arch/powerpc/kvm/book3s_pr.c | 1 + arch/powerpc/kvm/e500_mmu_host.c | 8 +- arch/powerpc/kvm/emulate_loadstore.c | 751 +++++++++++------------------------ arch/powerpc/kvm/powerpc.c | 299 +++++++++++--- 7 files changed, 498 insertions(+), 593 deletions(-)