From patchwork Mon May 5 01:27:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 4111391 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2BFE8BFF02 for ; Mon, 5 May 2014 01:29:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AF0812037A for ; Mon, 5 May 2014 01:28:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9EF8A20254 for ; Mon, 5 May 2014 01:28:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754047AbaEEB2y (ORCPT ); Sun, 4 May 2014 21:28:54 -0400 Received: from e23smtp01.au.ibm.com ([202.81.31.143]:34053 "EHLO e23smtp01.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753971AbaEEB2A (ORCPT ); Sun, 4 May 2014 21:28:00 -0400 Received: from /spool/local by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 May 2014 11:27:58 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 5 May 2014 11:27:56 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 8196D3578056; Mon, 5 May 2014 11:27:56 +1000 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s4516nFW3408228; Mon, 5 May 2014 11:06:49 +1000 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s451RtcU011512; Mon, 5 May 2014 11:27:56 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.190.163.12]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s451Rt6E011509; Mon, 5 May 2014 11:27:55 +1000 Received: from shangw (haven.au.ibm.com [9.190.164.82]) by ozlabs.au.ibm.com (Postfix) with ESMTP id 2B919A0117; Mon, 5 May 2014 11:27:55 +1000 (EST) Received: by shangw (Postfix, from userid 1000) id 19CFA3E0370; Mon, 5 May 2014 11:28:17 +1000 (EST) From: Gavin Shan To: linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Cc: alex.williamson@redhat.com, benh@kernel.crashing.org, aik@ozlabs.ru, qiudayu@linux.vnet.ibm.com, Gavin Shan Subject: [PATCH 09/22] powerpc/powernv: EEH RTAS emulation backend Date: Mon, 5 May 2014 11:27:58 +1000 Message-Id: <1399253291-3975-10-git-send-email-gwshan@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1399253291-3975-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1399253291-3975-1-git-send-email-gwshan@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14050501-1618-0000-0000-0000002C93E8 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The implementation of EEH RTAS emulation is split up into 2 layers: kvm and powernv platform layer. The KVM layer is quite simple to dispatch RTAS requests from guest to powernv platform layer. After that, the powernv platform layer takes care of the details, process the request and return result to kvm layer. The patch implements the infrastructure of powernv platform layer for EEH RTAS emulation. Signed-off-by: Gavin Shan --- arch/powerpc/include/asm/eeh.h | 18 +++++++++ arch/powerpc/platforms/powernv/Makefile | 1 + arch/powerpc/platforms/powernv/eeh-rtas.c | 64 +++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 arch/powerpc/platforms/powernv/eeh-rtas.c diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h index 677c719..7384dee 100644 --- a/arch/powerpc/include/asm/eeh.h +++ b/arch/powerpc/include/asm/eeh.h @@ -49,6 +49,24 @@ struct device_node; #define EEH_PE_RST_SETTLE_TIME 1800 #ifdef CONFIG_KVM_EEH + +/* + * Those EEH RTAS operations are going to be emulated. + * According to PAPR specification, there're much more + * operations. However, the following RTAS operations + * are enough for EEH in guest to work properly. + */ +enum { + eeh_rtas_first = 0, + eeh_rtas_set_option = 0, + eeh_rtas_set_slot_reset = 1, + eeh_rtas_read_slot_reset_state2 = 2, + eeh_rtas_get_config_addr_info2 = 3, + eeh_rtas_slot_error_detail = 4, + eeh_rtas_configure_pe = 5, + eeh_rtas_last = 5 +}; + struct eeh_vfio_pci_addr { struct kvm *kvm; /* KVM identifier */ unsigned int buid_hi; /* PHB BUID high */ diff --git a/arch/powerpc/platforms/powernv/Makefile b/arch/powerpc/platforms/powernv/Makefile index 63cebb9..d8ea670 100644 --- a/arch/powerpc/platforms/powernv/Makefile +++ b/arch/powerpc/platforms/powernv/Makefile @@ -6,5 +6,6 @@ obj-y += opal-msglog.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_PCI) += pci.o pci-p5ioc2.o pci-ioda.o obj-$(CONFIG_EEH) += eeh-ioda.o eeh-powernv.o +obj-$(CONFIG_KVM_EEH) += eeh-rtas.o obj-$(CONFIG_PPC_SCOM) += opal-xscom.o obj-$(CONFIG_MEMORY_FAILURE) += opal-memory-errors.o diff --git a/arch/powerpc/platforms/powernv/eeh-rtas.c b/arch/powerpc/platforms/powernv/eeh-rtas.c new file mode 100644 index 0000000..fded461 --- /dev/null +++ b/arch/powerpc/platforms/powernv/eeh-rtas.c @@ -0,0 +1,64 @@ +/* + * The file intends to implement emulation for EEH related RTAS services, + * which is expected to be done inside hypervisor. The specific RTAS + * service is identified by its unique token. Currently, the tokens + * are assigned by QEMU in a dynamic way and the dedicated hcall (0xf000) + * was introduced for the purpose of RTAS emulation either in hypervisor + * or QEMU. + * + * Copyright Benjamin Herrenschmidt & Gavin Shan, IBM Corporation 2014. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "powernv.h" +#include "pci.h" + +/** + * kvmppc_eeh_rtas - Backend for EEH RTAS emulation + * @vcpu: KVM virtual CPU + * @args: RTAS parameter + * @op: identifier of the specific EEH RTAS service + * + * The function will be called when the hypervisor receives emulation + * request on EEH RTAS from guest. Accordingly, it will dispatch to + * specific functions to handle the request. + */ +void kvmppc_eeh_rtas(struct kvm_vcpu *vcpu, struct rtas_args *args, int op) +{ + int ret = -3; + + /* Parse the requested service */ + switch (op) { + default: + pr_warn("%s: Unsupported EEH RTAS service#%d\n", + __func__, op); + } + + args->rets[0] = ret; +}