From patchwork Fri Aug 5 07:33:11 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: 9264853 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 5C9846048B for ; Fri, 5 Aug 2016 07:33:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52EBE2842D for ; Fri, 5 Aug 2016 07:33:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47B4F2842F; Fri, 5 Aug 2016 07:33:38 +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 426AD2842D for ; Fri, 5 Aug 2016 07:33:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751988AbcHEHde (ORCPT ); Fri, 5 Aug 2016 03:33:34 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:34612 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751930AbcHEHdc (ORCPT ); Fri, 5 Aug 2016 03:33:32 -0400 Received: by mail-pf0-f194.google.com with SMTP id g202so19746161pfb.1 for ; Fri, 05 Aug 2016 00:33:32 -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=EfpfeEgk2FdlD8F8o5L29Kt6PbzLj1zk2vI3/DzBw6s=; b=IIMhxS7bjrxo4r91Q+ywnG//MI+FuLMwa7F6q+xDUylX0hjN2jVr1rLqvk5kw9lQI1 khgStx/vLVeqyCtKVwtM/PCyTJPQIo5zUJ9sTGtTR9Np/5VbvnSxiaHEFyF8mIv89PgT mI+RayIJEQFZZB02FHdvLvVSOVNIeeRo4xE9W58nSxQwyOe3NnRSJ1C4b3xyZYrU8IYM Aw7Ow3082Un1un3lAUixvCspVShsmC8xBAFJ5zrmLxZN5aJcyF65lLgHUTYDaZ6OmBix 5hE//f+aZ2E/XM9QEfsR8PLgFI7H1HOc8xSkwMGZRI+nD92QeHfRShbLYw6oxCNqWW6H yaxQ== 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=EfpfeEgk2FdlD8F8o5L29Kt6PbzLj1zk2vI3/DzBw6s=; b=VACe/EK6n5kG9SjrwzWTRwJKaEnb/9f++NmP2gVjXRqFhrLBGdB3/97soVCzSjwwdN bLs+NBmYer56dKPwc+i2UdAp4dBlcRAky2pxThg7JjAufgsVMMm4A6v2Cc0Wt9JUhtYO 5mA/5brko9BRTb/WCjLzrjnhhImO+ZtaT3CHcB0QJzRJXk65rw0FgaCcXwSYQQwyNUIl 3S7RhUXLQ4cx7NS2Xaaibj1sxadM/KHbhP5evTEWT5k/Bxoapmr1micRmFC9RS+Ew+N5 YIqYmzxNNJreic8OXoeF6gF5E8kyl/0BC0kiDOeNZJBQBQ+3SOlQ1CyQDUTVaom6e3r0 oyIA== X-Gm-Message-State: AEkooutsupc+0NohEkGOwGQRTuICWW4LZjOhaKv0ccEVIePT4hjqigcBJIyvhVl/OHqK+Q== X-Received: by 10.98.29.201 with SMTP id d192mr133417263pfd.142.1470382411890; Fri, 05 Aug 2016 00:33:31 -0700 (PDT) Received: from dyn253.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id y2sm25383787pan.31.2016.08.05.00.33.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Aug 2016 00:33:31 -0700 (PDT) From: Suraj Jitindar Singh To: kvm@vger.kernel.org Cc: sjitindarsingh@gmail.com, drjones@redhat.com, pbonzini@redhat.com Subject: [kvm-unit-tests PATCH 2/4] lib/powerpc: Add generic decrementer exception handler Date: Fri, 5 Aug 2016 17:33:11 +1000 Message-Id: <1470382393-24209-2-git-send-email-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1470382393-24209-1-git-send-email-sjitindarsingh@gmail.com> References: <1470382393-24209-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 --- lib/powerpc/asm/handlers.h | 8 ++++++++ lib/powerpc/handlers.c | 26 ++++++++++++++++++++++++++ lib/ppc64/asm/handlers.h | 1 + powerpc/Makefile.common | 1 + 4 files changed, 36 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..1475052 --- /dev/null +++ b/lib/powerpc/asm/handlers.h @@ -0,0 +1,8 @@ +#ifndef _ASMPOWERPC_HANDLERS_H_ +#define _ASMPOWERPC_HANDLERS_H_ + +#include + +extern 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..1fb35d7 --- /dev/null +++ b/lib/powerpc/handlers.c @@ -0,0 +1,26 @@ +/* + * 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(__attribute__ ((unused)) struct pt_regs *regs, + __attribute__ ((unused)) void *data) +{ + 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)