From patchwork Tue Nov 7 10:47:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10046467 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B129360247 for ; Tue, 7 Nov 2017 11:06:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BB0829CEC for ; Tue, 7 Nov 2017 11:06:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8084929D1B; Tue, 7 Nov 2017 11:06:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 04E5529CEC for ; Tue, 7 Nov 2017 11:06:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=fNEfIAAAm/pMu+cqVEb5H6uY7o0Dfuk3StvgBTHki/c=; b=LsBKTwMZN3mOSRkX9Ww51f5X1Z qSlb9lQyzMuwRv26tw/x3n9LVlPWAV1Yio4T8hUovnh/asboGD7O7yL483y6VEcrSUepsTdXCGhCH iTbboo5hp7eAW9d+KT+9VyybmX4Qq3WS9NdfT+CMKfl+AlEJFusIf6rZ6Xd1usPh6dpsnkBZO2A5U eGDHQy5DHaJyP2l3ydrVqC/szSSpEh1kOTiIFPFmBWRWWkNXl/QABX3+SyCE5WVGkln9jyYN6Jven uZkVVOMLc9RiEbQxZMzYZGx9VBv/Bx4OV/SHQnMO21tbJHcZRwZn9ur+FDN62PFXPg/xbhrEJKa0b ntzB7g8g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eC1iO-00032r-GB; Tue, 07 Nov 2017 11:06:44 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eC1RP-0001XK-FJ for linux-arm-kernel@bombadil.infradead.org; Tue, 07 Nov 2017 10:49:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=64wG48JBPKZPsEEK6MA8jT4TaNacalxve8cFA/uPMR0=; b=a9a2TQJ4OM10LSlHRg/IxzJ1j k6wSVyB89RFncPsEZiXpV3M+0seiOlcFiAB7siv2MwnNZeA3jrrE8CBv9mSAWJLl3NlwRcsKlfVZE 9dKphr+TXpJjz6RqV343EcYGb8M9GrtXcS23gPgSvzwiRpN2BdYqI6X2zVx2skkv+YixBy4UtLk7c IUrdy0UO5EG0DWlvnB5wbVx/z6MqCBJ652EcWTcXFudhxGB6WpuT0RhEluEj/zYYjJuuhqstZObXj caDfRrF+xkCcz3OKaLX5CrjeDF1bSK91fOjl3mk+qwVJh0kS+pogXJ/SmlRHe8Ve/KjCs+4/Zf0ud UpKBik88w==; Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eC1RM-0005bD-Va for linux-arm-kernel@lists.infradead.org; Tue, 07 Nov 2017 10:49:10 +0000 Received: by mail-wm0-x241.google.com with SMTP id p75so2739501wmg.3 for ; Tue, 07 Nov 2017 02:48:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=64wG48JBPKZPsEEK6MA8jT4TaNacalxve8cFA/uPMR0=; b=YaIwmDd1CU+S2qyTeBaniAIwmfXvG0PmHwUM9Wa3oGLyYEDCMCMDO1nPgjLiPgXTrt UeqlumjFiIYgfXBvCdDQ1q97iMLwx3x02BaIpaibdWdrRw3tgXX2GCAKKpo7cdvArt/6 8jlaFQROHtW0V9xGQWvauXiDEMimlPRXZzAlE= 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; bh=64wG48JBPKZPsEEK6MA8jT4TaNacalxve8cFA/uPMR0=; b=Omv9VTsUN6ghdn+B6Hpo3LLAfcDXV9LpsWXiAWRdDHcicPsoPXpjJZ3KqA/JGlZksB 9mVQWcyKnGriLL+9inPUc4DKrl8ZDhQl8xAxJxFxP+DJ4pzSaoSAuEMjozsBDoK1J1K0 dXQ4HNwcgzUbyBDswRGXfKNvXQOjyaMPuUoQ53OYY4/a8BuOQwlCvs5NoVbBVpKtWDWJ jAbknSFWiuO42Cf5a68E5m10j78rk+QvvSQ0w8bdGf3BaJwIuAS25D0GzNfdsFfGfpkZ DCOc3Gb5vXOJEN0/YiP1HcutF6gIRzFKaYQxooX+TLGzs9humEhv05GAeV3F2GFSOLgK dgMg== X-Gm-Message-State: AMCzsaVdLvM9x7Aukm4iij8nEnrutjRNAIGPUZQbBjcDc7Kpg7pTbOhg yZ/siGeF8bnfwpSMFZ7jCZhluQ== X-Google-Smtp-Source: ABhQp+RPsklYtB4+lHEHwJ67PdoGmFas9mleLfTPzVU5Vbo4L2BEf51y7qa0wWod3PZjp5DQ9UaTAg== X-Received: by 10.80.219.10 with SMTP id o10mr23837208edk.259.1510051723747; Tue, 07 Nov 2017 02:48:43 -0800 (PST) Received: from localhost.localdomain (xd93dd96b.cust.hiper.dk. [217.61.217.107]) by smtp.gmail.com with ESMTPSA id q12sm1044958edj.29.2017.11.07.02.48.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Nov 2017 02:48:42 -0800 (PST) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 23/26] KVM: arm/arm64: Document KVM_DEV_ARM_ITS_CTRL_RESET Date: Tue, 7 Nov 2017 11:47:56 +0100 Message-Id: <20171107104800.30021-24-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171107104800.30021-1-christoffer.dall@linaro.org> References: <20171107104800.30021-1-christoffer.dall@linaro.org> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, Marc Zyngier , Eric Auger , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, Christoffer Dall MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Auger At the moment, the in-kernel emulated ITS is not properly reset. On guest restart/reset some registers keep their old values and internal structures like device, ITE, and collection lists are not freed. This may lead to various bugs. Among them, we can have incorrect state backup or failure when saving the ITS state at early guest boot stage. This patch documents a new attribute, KVM_DEV_ARM_ITS_CTRL_RESET in the KVM_DEV_ARM_VGIC_GRP_CTRL group. Upon this action, we can reset registers and especially those pointing to tables previously allocated by the guest and free the internal data structures storing the list of devices, collections and lpis. The usual approach for device reset of having userspace write the reset values of the registers to the kernel via the register read/write APIs doesn't work for the ITS because it has some internal state (caches) which is not exposed as registers, and there is no register interface for "drop cached data without writing it back to RAM". So we need a KVM API which mimics the hardware's reset line, to provide the equivalent behaviour to a "pull the power cord out of the back of the machine" reset. Reviewed-by: Christoffer Dall Reviewed-by: Marc Zyngier Signed-off-by: Eric Auger Reported-by: wanghaibin Signed-off-by: Christoffer Dall --- Documentation/virtual/kvm/devices/arm-vgic-its.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Documentation/virtual/kvm/devices/arm-vgic-its.txt b/Documentation/virtual/kvm/devices/arm-vgic-its.txt index eb06beb75960..8d5830eab26a 100644 --- a/Documentation/virtual/kvm/devices/arm-vgic-its.txt +++ b/Documentation/virtual/kvm/devices/arm-vgic-its.txt @@ -33,6 +33,10 @@ Groups: request the initialization of the ITS, no additional parameter in kvm_device_attr.addr. + KVM_DEV_ARM_ITS_CTRL_RESET + reset the ITS, no additional parameter in kvm_device_attr.addr. + See "ITS Reset State" section. + KVM_DEV_ARM_ITS_SAVE_TABLES save the ITS table data into guest RAM, at the location provisioned by the guest in corresponding registers/table entries. @@ -157,3 +161,19 @@ Then vcpus can be started. - pINTID is the physical LPI ID; if zero, it means the entry is not valid and other fields are not meaningful. - ICID is the collection ID + + ITS Reset State: + ---------------- + +RESET returns the ITS to the same state that it was when first created and +initialized. When the RESET command returns, the following things are +guaranteed: + +- The ITS is not enabled and quiescent + GITS_CTLR.Enabled = 0 .Quiescent=1 +- There is no internally cached state +- No collection or device table are used + GITS_BASER.Valid = 0 +- GITS_CBASER = 0, GITS_CREADR = 0, GITS_CWRITER = 0 +- The ABI version is unchanged and remains the one set when the ITS + device was first created.