From patchwork Fri Oct 6 15:59:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 115105 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2008153qgn; Fri, 6 Oct 2017 09:55:09 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBkaOsv2kLvmUHSoc/+0GKhs7Im4WCV0OEX+P7fltolw14jJMCMIt/7UwAak7xy+hX3PdxZ X-Received: by 10.237.43.228 with SMTP id e91mr4074704qtd.75.1507308909341; Fri, 06 Oct 2017 09:55:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507308909; cv=none; d=google.com; s=arc-20160816; b=C67hXns2HLh0HZxZB1egPrWhJ+UuMJFNXf1D1amD8tnM3VtVzp11hUPjphgQoqn4ck xK24CPNuFz6wvrTJQiuMsQU+ak7S13ryruYH9Xsq1P3tbqm/iRcbygBVSQykiof4LnIR hXIPA2rQIlusEB+LShNeqH4U6BNBwIyg5x4iZl0252YE0dm/H9pDuwX29xOYTJNma6oZ khWCJQ9H7qOYbfF528PcopTXUDJeRYBgVO9fdsF9Fe4Q73/ozRCLPi6Jyiax4XBEaHK7 fhCBW9jDZdBJf3jGxI53V1rY3gOD5vgu0LYXM/rmz5VzdVV3TgGVfYRE+ghH+MdlZGwN IAWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=Do07MzEksW4wyW9kJ+YUWExo7kK6xy+aWIpBkWKH9H0=; b=y7VXNPO2cOdylzcBxnJdUaFXyAiSeRZTU202kAjQz86cZmnQHyMpQU9eYfqoN9iM30 VgqrrPwUtJ0dudlEaKK8zZRMxjzw+gbz3L90uGi4uAQe6qFpQQ93RN7ld7557sub0Vy2 n4rkmV+Co/VXkj+pj9dWBdkNWKR075WR8j2VUK9ewAd9mc2K9BlrfyCvxU92BTREnxaN i+xWS4mvYOhy/2ZFDmAIVXx37cwNrf7vqTdz7vPKENviOe6D7RURCi2C7B4EnLbugyjN B5vGKV21briTI+kx0aaSCdzR720vPV4t0J8PN4aW8B1XYVq6kKJRp0xzzHV2Vvf8yjrk a97A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v201si1541006qka.435.2017.10.06.09.55.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 06 Oct 2017 09:55:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45991 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0Vu1-0002Ki-0G for patch@linaro.org; Fri, 06 Oct 2017 12:55:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58271) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0V1q-0004Ng-1a for qemu-devel@nongnu.org; Fri, 06 Oct 2017 11:59:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e0V1l-0007qv-J9 for qemu-devel@nongnu.org; Fri, 06 Oct 2017 11:59:10 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37712) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e0V1l-0007eF-AN for qemu-devel@nongnu.org; Fri, 06 Oct 2017 11:59:05 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1e0V1a-0002se-0F for qemu-devel@nongnu.org; Fri, 06 Oct 2017 16:58:54 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 6 Oct 2017 16:59:29 +0100 Message-Id: <1507305585-20608-5-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507305585-20608-1-git-send-email-peter.maydell@linaro.org> References: <1507305585-20608-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 04/20] nvic: Clear the vector arrays and prigroup on reset X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reset for devices does not include an automatic clear of the device state (unlike CPU state, where most of the state structure is cleared to zero). Add some missing initialization of NVIC state that meant that the device was left in the wrong state if the guest did a warm reset. (In particular, since we were resetting the computed state like s->exception_prio but not all the state it was computed from like s->vectors[x].active, the NVIC wound up in an inconsistent state that could later trigger assertion failures.) Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-id: 1506092407-26985-2-git-send-email-peter.maydell@linaro.org --- hw/intc/armv7m_nvic.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.7.4 diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index d90d8d0..bc7b66d 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -1782,6 +1782,11 @@ static void armv7m_nvic_reset(DeviceState *dev) int resetprio; NVICState *s = NVIC(dev); + memset(s->vectors, 0, sizeof(s->vectors)); + memset(s->sec_vectors, 0, sizeof(s->sec_vectors)); + s->prigroup[M_REG_NS] = 0; + s->prigroup[M_REG_S] = 0; + s->vectors[ARMV7M_EXCP_NMI].enabled = 1; /* MEM, BUS, and USAGE are enabled through * the System Handler Control register