From patchwork Fri Oct 16 13:57:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 55116 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by patches.linaro.org (Postfix) with ESMTPS id 0F86022EAC for ; Fri, 16 Oct 2015 14:06:27 +0000 (UTC) Received: by lbcao8 with SMTP id ao8sf24812651lbc.1 for ; Fri, 16 Oct 2015 07:06:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=b8pBbJ8zIoEsZFx2mII/rUC/U9cw24JyXeOrV+sFTL8=; b=essZIuUxLFWKlCmZ1SOFFDqkgVhDCpVdoXyY5v/Rz5PC5QCx4LZKjR+rt3CW2ux4h9 dOwYSeb7iqw+wQkAHi02OAccoe5LrzzJYDlOqgL5fySAuUMP2zJDhvENqtILu0yFBFeF AHhtEbPca6YaS/ImWv6I6TnY3WZzGs1qK8/QBGG0uJM9iSlFEc2ODYOCPdFU4B3GpxWH czaH4tuyoR1TtuJAsQaY1SFkmNt/DDvZiiPA/wGl74auEDog4XIqnwsohSIBSMBZxJga X38qP7FOOUP1ctgSRcjEY+XDLZW50mrvvhuQI1WUjvVDYnR135XVuqSx3bPQyuAQkc4G cDLQ== X-Gm-Message-State: ALoCoQmfdlW9e8d9OeGEi85ZBPGvJgr9JtOpGycaauNnMqt02BrS/L20vYv+k2ifaPURaUHLldOI X-Received: by 10.194.118.65 with SMTP id kk1mr3627518wjb.5.1445004386026; Fri, 16 Oct 2015 07:06:26 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.153.196 with SMTP id b187ls325336lfe.80.gmail; Fri, 16 Oct 2015 07:06:25 -0700 (PDT) X-Received: by 10.112.55.2 with SMTP id n2mr8545363lbp.59.1445004385724; Fri, 16 Oct 2015 07:06:25 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id e136si13025302lfb.88.2015.10.16.07.06.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Oct 2015 07:06:25 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by lbbwb3 with SMTP id wb3so39859128lbb.1 for ; Fri, 16 Oct 2015 07:06:25 -0700 (PDT) X-Received: by 10.112.202.35 with SMTP id kf3mr8429675lbc.19.1445004385604; Fri, 16 Oct 2015 07:06:25 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1312737lbq; Fri, 16 Oct 2015 07:06:24 -0700 (PDT) X-Received: by 10.140.19.175 with SMTP id 44mr19065800qgh.50.1445004384350; Fri, 16 Oct 2015 07:06:24 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 86si18038369qky.58.2015.10.16.07.06.24 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 16 Oct 2015 07:06:24 -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; Received: from localhost ([::1]:53887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zn5eJ-0004Xt-Vj for patch@linaro.org; Fri, 16 Oct 2015 10:06:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55073) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zn5WP-00021b-0V for qemu-devel@nongnu.org; Fri, 16 Oct 2015 09:58:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zn5WN-0000ma-LN for qemu-devel@nongnu.org; Fri, 16 Oct 2015 09:58:12 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:35158) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zn5WN-0000ht-Dc for qemu-devel@nongnu.org; Fri, 16 Oct 2015 09:58:11 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1Zn5WJ-0003mG-NT for qemu-devel@nongnu.org; Fri, 16 Oct 2015 14:58:07 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 16 Oct 2015 14:57:59 +0100 Message-Id: <1445003887-14475-6-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1445003887-14475-1-git-send-email-peter.maydell@linaro.org> References: <1445003887-14475-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Subject: [Qemu-devel] [PULL 05/13] target-arm: Implement AArch64 OSLAR/OSLSR_EL1 sysregs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 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-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Davorin Mista Added oslar_write function to OSLAR_EL1 sysreg, using a status variable in ARMCPUState.cp15 struct (oslsr_el1). This variable is also linked to the newly added read-only OSLSR_EL1 register. Linux reads from this register during its suspend/resume procedure. Signed-off-by: Davorin Mista [PMM: folded a long line and tweaked a comment] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target-arm/cpu.h | 1 + target-arm/helper.c | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 5fb0479..d1b5bc1 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -379,6 +379,7 @@ typedef struct CPUARMState { uint64_t dbgwvr[16]; /* watchpoint value registers */ uint64_t dbgwcr[16]; /* watchpoint control registers */ uint64_t mdscr_el1; + uint64_t oslsr_el1; /* OS Lock Status */ /* If the counter is enabled, this stores the last time the counter * was reset. Otherwise it stores the counter value */ diff --git a/target-arm/helper.c b/target-arm/helper.c index b2d78b0..403a30e 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -3568,6 +3568,23 @@ static CPAccessResult ctr_el0_access(CPUARMState *env, const ARMCPRegInfo *ri) return CP_ACCESS_OK; } +static void oslar_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + /* Writes to OSLAR_EL1 may update the OS lock status, which can be + * read via a bit in OSLSR_EL1. + */ + int oslock; + + if (ri->state == ARM_CP_STATE_AA32) { + oslock = (value == 0xC5ACCE55); + } else { + oslock = value & 1; + } + + env->cp15.oslsr_el1 = deposit32(env->cp15.oslsr_el1, 1, 1, oslock); +} + static const ARMCPRegInfo debug_cp_reginfo[] = { /* DBGDRAR, DBGDSAR: always RAZ since we don't implement memory mapped * debug components. The AArch64 version of DBGDRAR is named MDRAR_EL1; @@ -3596,10 +3613,14 @@ static const ARMCPRegInfo debug_cp_reginfo[] = { .type = ARM_CP_ALIAS, .access = PL1_R, .fieldoffset = offsetof(CPUARMState, cp15.mdscr_el1), }, - /* We define a dummy WI OSLAR_EL1, because Linux writes to it. */ { .name = "OSLAR_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 4, - .access = PL1_W, .type = ARM_CP_NOP }, + .access = PL1_W, .type = ARM_CP_NO_RAW, + .writefn = oslar_write }, + { .name = "OSLSR_EL1", .state = ARM_CP_STATE_BOTH, + .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 4, + .access = PL1_R, .resetvalue = 10, + .fieldoffset = offsetof(CPUARMState, cp15.oslsr_el1) }, /* Dummy OSDLR_EL1: 32-bit Linux will read this */ { .name = "OSDLR_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 1, .crm = 3, .opc2 = 4,