From patchwork Thu Dec 5 12:39:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 22058 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f69.google.com (mail-qe0-f69.google.com [209.85.128.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 90DF523FD0 for ; Thu, 5 Dec 2013 12:39:49 +0000 (UTC) Received: by mail-qe0-f69.google.com with SMTP id 1sf33553928qec.8 for ; Thu, 05 Dec 2013 04:39:49 -0800 (PST) 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:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=MBjsdaH7SQGV1omc1aSqzazdYFPBEm2WxoUSNzSYRaE=; b=VUvUC3u/b0utbx75Owoipb1tAgte73nMvEWS1DKJdrJ9EdUt6/SpnB6LcDIvZZbbQm LTKNBl92T9XcSxsKtuFoy3rdCUqnUk4ogPRgmJwR/Yafnm9KKVX2zy0K+JY0wY8AbW5S u6z3Jq0H9AzHNVvnxrxO0x66/md0OccjdV1vKow7G2CMNjEDB3o0rxB7Mv7sk74j4add zDMezqHNHrI/2wZWa2+niDAXPOYaYDvIG6QbVIuh2S2wQhXFBRYuRXreGMwpgWDuvp0j DECWBT6ti/r+DHHItNQlx81YdtKbb4FLNixfGQkJx0t4HkYX7XOLb7i9CL56kDOtMv9D L44Q== X-Gm-Message-State: ALoCoQl9rqbBrbZSV3LmiTUJP1k+7AofhnUz+R1N0yFMZJX1XKzv8MhQ3VvQtKkuPJ2Tsn24NEhK X-Received: by 10.52.229.41 with SMTP id sn9mr16273445vdc.6.1386247188969; Thu, 05 Dec 2013 04:39:48 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.128.41 with SMTP id nl9ls828304qeb.56.gmail; Thu, 05 Dec 2013 04:39:48 -0800 (PST) X-Received: by 10.52.157.38 with SMTP id wj6mr109410vdb.63.1386247188820; Thu, 05 Dec 2013 04:39:48 -0800 (PST) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id z17si22645666vcy.83.2013.12.05.04.39.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Dec 2013 04:39:48 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id ld13so12731422vcb.20 for ; Thu, 05 Dec 2013 04:39:48 -0800 (PST) X-Received: by 10.52.168.106 with SMTP id zv10mr53328362vdb.21.1386247188616; Thu, 05 Dec 2013 04:39:48 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp11814vcz; Thu, 5 Dec 2013 04:39:48 -0800 (PST) X-Received: by 10.205.33.141 with SMTP id so13mr55474788bkb.24.1386247185705; Thu, 05 Dec 2013 04:39:45 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id oj6si24559171bkb.174.2013.12.05.04.39.44 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 05 Dec 2013 04:39:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1VoYDV-00072J-1W; Thu, 05 Dec 2013 12:39:41 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Michael Matz , C Fontana , Dirk Mueller , Laurent Desnogues , kvmarm@lists.cs.columbia.edu, Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH v3 07/12] target-arm: A64: expand decoding skeleton for system instructions Date: Thu, 5 Dec 2013 12:39:35 +0000 Message-Id: <1386247180-26994-8-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1386247180-26994-1-git-send-email-peter.maydell@linaro.org> References: <1386247180-26994-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Claudio Fontana Decode the various kinds of system instructions: hints (HINT), which include NOP, YIELD, WFE, WFI, SEV, SEL sync instructions, which include CLREX, DSB, DMB, ISB msr_i, which move immediate to processor state field sys, which include all SYS and SYSL instructions msr, which move from a gp register to a system register mrs, which move from a system register to a gp register Provide implementations where they are trivial nops. Signed-off-by: Claudio Fontana Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target-arm/translate-a64.c | 131 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 129 insertions(+), 2 deletions(-) diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c index 8e16cb1..1e2b371 100644 --- a/target-arm/translate-a64.c +++ b/target-arm/translate-a64.c @@ -190,12 +190,139 @@ static void disas_cond_b_imm(DisasContext *s, uint32_t insn) unsupported_encoding(s, insn); } -/* System */ -static void disas_system(DisasContext *s, uint32_t insn) +/* C5.6.68 HINT */ +static void handle_hint(DisasContext *s, uint32_t insn, + unsigned int op1, unsigned int op2, unsigned int crm) +{ + unsigned int selector = crm << 3 | op2; + + if (op1 != 3) { + unallocated_encoding(s); + return; + } + + switch (selector) { + case 0: /* NOP */ + return; + case 1: /* YIELD */ + case 2: /* WFE */ + case 3: /* WFI */ + case 4: /* SEV */ + case 5: /* SEVL */ + /* we treat all as NOP at least for now */ + return; + default: + /* default specified as NOP equivalent */ + return; + } +} + +/* CLREX, DSB, DMB, ISB */ +static void handle_sync(DisasContext *s, uint32_t insn, + unsigned int op1, unsigned int op2, unsigned int crm) +{ + if (op1 != 3) { + unallocated_encoding(s); + return; + } + + switch (op2) { + case 2: /* CLREX */ + unsupported_encoding(s, insn); + return; + case 4: /* DSB */ + case 5: /* DMB */ + case 6: /* ISB */ + /* We don't emulate caches so barriers are no-ops */ + return; + default: + unallocated_encoding(s); + return; + } +} + +/* C5.6.130 MSR (immediate) - move immediate to processor state field */ +static void handle_msr_i(DisasContext *s, uint32_t insn, + unsigned int op1, unsigned int op2, unsigned int crm) { unsupported_encoding(s, insn); } +/* C5.6.204 SYS */ +static void handle_sys(DisasContext *s, uint32_t insn, unsigned int l, + unsigned int op1, unsigned int op2, + unsigned int crn, unsigned int crm, unsigned int rt) +{ + unsupported_encoding(s, insn); +} + +/* C5.6.129 MRS - move from system register */ +static void handle_mrs(DisasContext *s, uint32_t insn, unsigned int op0, + unsigned int op1, unsigned int op2, + unsigned int crn, unsigned int crm, unsigned int rt) +{ + unsupported_encoding(s, insn); +} + +/* C5.6.131 MSR (register) - move to system register */ +static void handle_msr(DisasContext *s, uint32_t insn, unsigned int op0, + unsigned int op1, unsigned int op2, + unsigned int crn, unsigned int crm, unsigned int rt) +{ + unsupported_encoding(s, insn); +} + +/* C3.2.4 System + * 31 22 21 20 19 18 16 15 12 11 8 7 5 4 0 + * +---------------------+---+-----+-----+-------+-------+-----+------+ + * | 1 1 0 1 0 1 0 1 0 0 | L | op0 | op1 | CRn | CRm | op2 | Rt | + * +---------------------+---+-----+-----+-------+-------+-----+------+ + */ +static void disas_system(DisasContext *s, uint32_t insn) +{ + unsigned int l, op0, op1, crn, crm, op2, rt; + l = extract32(insn, 21, 1); + op0 = extract32(insn, 19, 2); + op1 = extract32(insn, 16, 3); + crn = extract32(insn, 12, 4); + crm = extract32(insn, 8, 4); + op2 = extract32(insn, 5, 3); + rt = extract32(insn, 0, 5); + + if (op0 == 0) { + if (l || rt != 31) { + unallocated_encoding(s); + return; + } + switch (crn) { + case 2: /* C5.6.68 HINT */ + handle_hint(s, insn, op1, op2, crm); + break; + case 3: /* CLREX, DSB, DMB, ISB */ + handle_sync(s, insn, op1, op2, crm); + break; + case 4: /* C5.6.130 MSR (immediate) */ + handle_msr_i(s, insn, op1, op2, crm); + break; + default: + unallocated_encoding(s); + break; + } + return; + } + + if (op0 == 1) { + /* C5.6.204 SYS */ + handle_sys(s, insn, l, op1, op2, crn, crm, rt); + } else if (l) { /* op0 > 1 */ + /* C5.6.129 MRS - move from system register */ + handle_mrs(s, insn, op0, op1, op2, crn, crm, rt); + } else { + /* C5.6.131 MSR (register) - move to system register */ + handle_msr(s, insn, op0, op1, op2, crn, crm, rt); + } +} + /* Exception generation */ static void disas_exc(DisasContext *s, uint32_t insn) {