From patchwork Tue Aug 16 07:18:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suraj Jitindar Singh X-Patchwork-Id: 9282731 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 5F5C660574 for ; Tue, 16 Aug 2016 07:18:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 499B828682 for ; Tue, 16 Aug 2016 07:18:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E3052868A; Tue, 16 Aug 2016 07:18:49 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D92D528682 for ; Tue, 16 Aug 2016 07:18:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751425AbcHPHSp (ORCPT ); Tue, 16 Aug 2016 03:18:45 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:34988 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751226AbcHPHSo (ORCPT ); Tue, 16 Aug 2016 03:18:44 -0400 Received: by mail-pa0-f65.google.com with SMTP id cf3so4827662pad.2; Tue, 16 Aug 2016 00:18:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SZ09pKd3AeNay+lKiRIiANPdk1TYRYctbR7Ee87UTFg=; b=fOgNQRCIwaGuGdwSBLacM0VWrilt9FzgonD5qppr7kudN1+VfjHsNrv6hIYDz7N/fX +A1mtxoZSSzVyf4KrJO3Tw8W1+uBXMDjIP+Jve2j8rUcfspu7RD6FlBUo/qceym5tNFI tBkkXGkFlxGvXpMa/enq53do1vgJdYoulJuR6bDnl581DfzD/lkVhc6/R1fTPJus93gI 9K3xZdwXa0Cy3XbE2u50eWGslqD6abi7YsiuD2vobgU160HOidVQw89vpZXq8sorUG4K QJnmQJHXjm78wCJFr9kwWIuRPHCpgzI24guPKvMcc5Jnek7W4iPiopH4tAfU6gx7n2Qs I1yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SZ09pKd3AeNay+lKiRIiANPdk1TYRYctbR7Ee87UTFg=; b=k3yWhO1U0380805mlYpnXfRxs4yRMaj7kQwbQRnZw6dRlwmJOXKOsosQYRybMcaIDS 4az5bg4ATxa4GRTXcME6zyDyJjOJxf1n3ZOTa/a6Fw1Q56Wzmz6jmOztSOKiy0EsFukq Tiahnxw180UFXGB3MqWLupfZ+sHLPhEJhSmxcMA9dNp8u9aIpJ+WKKmmr2pueFGq0JYQ nYvb0D+pO3nAjOd9rhBMpB5nmDaEgPipGXKVnc05u+VBcV8s/Pz5PpNMwB5LVQtgqNv6 k2cmaV2h+dw5asqX/RB7DpqKm6vcYaL3/HgOhw13t6LiAVkCxZb8tkm/1U+bIJimkjVL aP/g== X-Gm-Message-State: AEkooutocJviRhyKdKTQs5lZQrYxQWV01xtW3bBC2kdn8bmvyD1YbhIxQvZ1Ljthxqfo3w== X-Received: by 10.66.62.164 with SMTP id z4mr46092296par.156.1471331923640; Tue, 16 Aug 2016 00:18:43 -0700 (PDT) Received: from dyn253.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id fj19sm36452252pab.37.2016.08.16.00.18.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Aug 2016 00:18:43 -0700 (PDT) From: Suraj Jitindar Singh To: kvm@vger.kernel.org Cc: sjitindarsingh@gmail.com, pbonzini@redhat.com, rkrcmar@redhat.com, kvm-ppc@vger.kernel.org, lvivier@redhat.com, thuth@redhat.com, drjones@redhat.com Subject: [kvm-unit-tests PATCH V3 2/5] lib/powerpc: Add generic decrementer exception handler Date: Tue, 16 Aug 2016 17:18:12 +1000 Message-Id: <1471331895-29887-2-git-send-email-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1471331895-29887-1-git-send-email-sjitindarsingh@gmail.com> References: <1471331895-29887-1-git-send-email-sjitindarsingh@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add the lib/powerpc/handlers.c file and associated header files as a place to implement generic exception handler functions for inclusion in tests. Add a generic exception handler for a decrementer (0x900) interrupt which will reset the decrementer to its maximum value. Signed-off-by: Suraj Jitindar Singh Reviewed-by: Thomas Huth Reviewed-by: Andrew Jones --- Change Log: V2 -> V3: - Whitespace changes Signed-off-by: Suraj Jitindar Singh --- lib/powerpc/asm/handlers.h | 8 ++++++++ lib/powerpc/handlers.c | 22 ++++++++++++++++++++++ lib/ppc64/asm/handlers.h | 1 + powerpc/Makefile.common | 1 + 4 files changed, 32 insertions(+) create mode 100644 lib/powerpc/asm/handlers.h create mode 100644 lib/powerpc/handlers.c create mode 100644 lib/ppc64/asm/handlers.h diff --git a/lib/powerpc/asm/handlers.h b/lib/powerpc/asm/handlers.h new file mode 100644 index 0000000..64ba727 --- /dev/null +++ b/lib/powerpc/asm/handlers.h @@ -0,0 +1,8 @@ +#ifndef _ASMPOWERPC_HANDLERS_H_ +#define _ASMPOWERPC_HANDLERS_H_ + +#include + +void dec_except_handler(struct pt_regs *regs, void *data); + +#endif /* _ASMPOWERPC_HANDLERS_H_ */ diff --git a/lib/powerpc/handlers.c b/lib/powerpc/handlers.c new file mode 100644 index 0000000..be8226a --- /dev/null +++ b/lib/powerpc/handlers.c @@ -0,0 +1,22 @@ +/* + * Generic exception handlers for registration and use in tests + * + * Copyright 2016 Suraj Jitindar Singh, IBM. + * + * This work is licensed under the terms of the GNU LGPL, version 2. + */ + +#include +#include +#include + +/* + * Generic handler for decrementer exceptions (0x900) + * Just reset the decrementer back to its maximum value (0x7FFFFFFF) + */ +void dec_except_handler(struct pt_regs *regs __unused, void *data __unused) +{ + uint32_t dec = 0x7FFFFFFF; + + asm volatile ("mtdec %0" : : "r" (dec)); +} diff --git a/lib/ppc64/asm/handlers.h b/lib/ppc64/asm/handlers.h new file mode 100644 index 0000000..92e6fb2 --- /dev/null +++ b/lib/ppc64/asm/handlers.h @@ -0,0 +1 @@ +#include "../../powerpc/asm/handlers.h" diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common index 3f8887d..404194b 100644 --- a/powerpc/Makefile.common +++ b/powerpc/Makefile.common @@ -36,6 +36,7 @@ cflatobjs += lib/powerpc/hcall.o cflatobjs += lib/powerpc/setup.o cflatobjs += lib/powerpc/rtas.o cflatobjs += lib/powerpc/processor.o +cflatobjs += lib/powerpc/handlers.o FLATLIBS = $(libcflat) $(LIBFDT_archive) %.elf: CFLAGS += $(arch_CFLAGS)