From patchwork Wed Aug 10 01:59:35 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: 9272513 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 3BA43601C2 for ; Wed, 10 Aug 2016 02:18:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A59D2833F for ; Wed, 10 Aug 2016 02:18:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F355C2835B; Wed, 10 Aug 2016 02:18:17 +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 9CE222833F for ; Wed, 10 Aug 2016 02:18:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932697AbcHJCSO (ORCPT ); Tue, 9 Aug 2016 22:18:14 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:32920 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932654AbcHJCSN (ORCPT ); Tue, 9 Aug 2016 22:18:13 -0400 Received: by mail-pf0-f193.google.com with SMTP id i6so1886733pfe.0; Tue, 09 Aug 2016 19:18:13 -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=8aUF4GjhBjKs0JBz6Y42kDpWX4+fStUDxIs18MoWhoI=; b=lXayQ3GiTjzQdsD8mAPzRToT0iaUNtSLj63yl0nL2d9cDXB7C28sRnyyR37TOTSETc xwUkwsdvkEX/SUUULJxRKl653weVFgwFcKafhg/i2+kqc5u8g7USgpu/jGCHdYd8cis4 fkxjRN6wGeNfrC34thmGJoY2pxRro7ca7Utc0+15FXhYKz/dWH98AeJsmcbuztJ88HBx MjBnreB7uKSE0A++7Spn6YdpY4iARYLifSkluw/sK/HlRL7Zg5fJxIDzO59rDSz2oskD ps1nl10VrC7jgzUbUmj4mx+WU03gwBV7ev55fATGG6ALcA+I04PEQOlXMa/c1zRkV1Jy VQWw== 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=8aUF4GjhBjKs0JBz6Y42kDpWX4+fStUDxIs18MoWhoI=; b=iMYeiArzFbtS8YXm2tbPWiCq8OWSVP59CkoY0LWWvHOWIaKrAe0Mwmz72whjpfVcD4 Ueplzdc/gzjAROXqHhM+A4VYxcmlhMQK+9/j4Gusnlf6FsfAFUZa2CMGN8HeFIJTkhv+ QRkRofVhQ1NTqMWJ8GA9oYULpt6DPKx3w4rt1M5WwkLKmStqqZ6hiG3v+VSC3zndM80R E22K58Cl+vgdFbO2lFcmQa79kwDNEWT/T3kHNByz6qdJPb7HLoafliv8ExTLluYnNQc5 vBNZaYsX7QexVVTC3MZAZAFtK9jC4JInE16dzbn73zTi/9rc98k9f8lxpzr5OYqBwVKe ks3w== X-Gm-Message-State: AEkoouuVVhGQ7e3MhA+6czE35cQR6h6YZZgsmf8Q6CsI/EVsoDJ2gQB6FRyke0FMPmN24g== X-Received: by 10.98.205.6 with SMTP id o6mr2533189pfg.37.1470794397098; Tue, 09 Aug 2016 18:59:57 -0700 (PDT) Received: from dyn253.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id n69sm58888633pfa.77.2016.08.09.18.59.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Aug 2016 18:59:56 -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 V2 2/4] lib/powerpc: Add generic decrementer exception handler Date: Wed, 10 Aug 2016 11:59:35 +1000 Message-Id: <1470794377-14427-2-git-send-email-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1470794377-14427-1-git-send-email-sjitindarsingh@gmail.com> References: <1470794377-14427-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 --- lib/powerpc/asm/handlers.h | 8 ++++++++ lib/powerpc/handlers.c | 25 +++++++++++++++++++++++++ lib/ppc64/asm/handlers.h | 1 + powerpc/Makefile.common | 1 + 4 files changed, 35 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..6a621f1 --- /dev/null +++ b/lib/powerpc/handlers.c @@ -0,0 +1,25 @@ +/* + * 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)