From patchwork Wed Mar 16 15:13:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 8601761 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0E3E2C0553 for ; Wed, 16 Mar 2016 15:14:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 936D72034B for ; Wed, 16 Mar 2016 15:14:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E89E520351 for ; Wed, 16 Mar 2016 15:14:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966848AbcCPPO0 (ORCPT ); Wed, 16 Mar 2016 11:14:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41443 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966847AbcCPPOZ (ORCPT ); Wed, 16 Mar 2016 11:14:25 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 0527012B28; Wed, 16 Mar 2016 15:14:25 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-112-23.ams2.redhat.com [10.36.112.23]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2GFE6kl016192; Wed, 16 Mar 2016 11:14:22 -0400 From: Laurent Vivier To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Cc: drjones@redhat.com, thuth@redhat.com, dgibson@redhat.com, pbonzini@redhat.com, Laurent Vivier Subject: [kvm-unit-tests PATCH 5/5] powerpc: Check lswx in little-endian mode. Date: Wed, 16 Mar 2016 16:13:03 +0100 Message-Id: <1458141183-27207-6-git-send-email-lvivier@redhat.com> In-Reply-To: <1458141183-27207-1-git-send-email-lvivier@redhat.com> References: <1458141183-27207-1-git-send-email-lvivier@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 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 For lswx in little-endian mode, an alignment interrupt occurs. Signed-off-by: Laurent Vivier Reviewed-by: Thomas Huth --- powerpc/emulator.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/powerpc/emulator.c b/powerpc/emulator.c index dfe5859..3a8f17e 100644 --- a/powerpc/emulator.c +++ b/powerpc/emulator.c @@ -6,6 +6,7 @@ #include static int volatile is_invalid; +static int volatile alignment; static void program_check_handler(struct pt_regs *regs, void *opaque) { @@ -19,6 +20,18 @@ static void program_check_handler(struct pt_regs *regs, void *opaque) regs->nip += 4; } +static void alignment_handler(struct pt_regs *regs, void *opaque) +{ + int *data = opaque; + + printf("Detected alignment exception 0x%016lx: %08x\n", + regs->nip, *(uint32_t*)regs->nip); + + *data = 1; + + regs->nip += 4; +} + static void test_illegal(void) { report_prefix_push("invalid"); @@ -62,6 +75,8 @@ static void test_64bit(void) * - RT <= RA or RB < RT + (n + 4) is invalid or result is undefined * - RT == RA == 0 is invalid * + * For lswx in little-endian mode, an alignment interrupt always occurs. + * */ #define SPR_XER 1 @@ -81,6 +96,7 @@ static void test_lswx(void) /* check incomplete register filling */ + alignment = 0; asm volatile ("mtspr %[XER], %[len];" "li r12,-1;" "mr r11, r12;" @@ -98,7 +114,12 @@ static void test_lswx(void) */ "xer", "r11", "r12"); +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + report("alignment", alignment); + return; +#else report("partial", regs[0] == 0x01020300 && regs[1] == (uint64_t)-1); +#endif /* check an old know bug: the number of bytes is used as * the number of registers, so try 32 bytes. @@ -195,6 +216,7 @@ static void test_lswx(void) int main(void) { handle_exception(0x700, program_check_handler, (void *)&is_invalid); + handle_exception(0x600, alignment_handler, (void *)&alignment); report_prefix_push("emulator");