mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
s390x/kvm/watchdog
1. Implement a diag288 based watchdog 2. Fix virtio-ccw BIOS for gcc >= 4.9 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (GNU/Linux) iQIcBAABAgAGBQJVfri5AAoJEBF7vIC1phx8ME4P/AgMYstY5sjzmSYKAXLhwmZl vDaxZ1MqoRZQfzPWXcPGavNFb9lnebLkedWO4FvYWWoVRxUHThKF2d5PDz8qsS7C lNhp0YNiMHcvSv8mlAr9TVP3ssKbp0YFyhZAIEtjlAesnbHl0URfPUulx0TpKHsg EqEiwFPB+eUHD1GiBa+x7bTCnyp8Ppn9SrGItJR0Mq7AjLzvjtwATPZbLk+I6mwN Nqd0uhYScbi6NX4UlifzaYYePjAQmN2ZhLwzuasqHhhJtAm8M6EPXkwxb9X5elWJ cZmCEkYMD+j5G6Lqm3ZV44g1fSM9k4ZctcOUpQzPmS+sDj48ydDDkgy/hiY/Fu6e Xf3Ti6ChSQMjQc9vcYWHtdAt+rvYAxOqTK//hHp87MADsREYjhVXVBMubJZ5h+z0 eEtuKo6npZg1AD8lFdCMEyvqWHqldVYiZfJwTBoCbX26bEpkbQhy11PjD7Sm3lP0 EVad06C1Rv4Gr6uiL+4Pqulm6G8CqATiLMUrE9VkI7WhtwOa81OQS6v+dlVIERLF ueKt7bhCBIQrmdsAsNlC5nvP39pCkkBjogdw+S7UttTFA9KEKr8gMjHVAdNNk/Or OBi1YBJOCc2CcE/0mVpC8okgprOP3AOjPGn+wmlRNw2s3TOlmVN/rz/d6lr/rPFV VIpdMY0RuQSQY36qUdEo =WVga -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/borntraeger/tags/s390x-20150615' into staging s390x/kvm/watchdog 1. Implement a diag288 based watchdog 2. Fix virtio-ccw BIOS for gcc >= 4.9 # gpg: Signature made Mon Jun 15 12:36:25 2015 BST using RSA key ID B5A61C7C # gpg: Good signature from "Christian Borntraeger (IBM) <borntraeger@de.ibm.com>" * remotes/borntraeger/tags/s390x-20150615: s390/bios: build with -fdelete-null-pointer-checks watchdog: Add new Virtual Watchdog action INJECT-NMI nmi: Implement inject_nmi() for non-monitor context use s390x/watchdog: diag288 migration support s390x/kvm: diag288 instruction interception and handling s390x/watchdog: introduce diag288 watchdog device watchdog: change option wording to allow for more watchdogs Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
46bca5404b
13 changed files with 262 additions and 11 deletions
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "hw/nmi.h"
|
||||
#include "qapi/qmp/qerror.h"
|
||||
#include "monitor/monitor.h"
|
||||
|
||||
struct do_nmi_s {
|
||||
int cpu_index;
|
||||
|
@ -70,6 +71,25 @@ void nmi_monitor_handle(int cpu_index, Error **errp)
|
|||
}
|
||||
}
|
||||
|
||||
void inject_nmi(void)
|
||||
{
|
||||
#if defined(TARGET_I386)
|
||||
CPUState *cs;
|
||||
|
||||
CPU_FOREACH(cs) {
|
||||
X86CPU *cpu = X86_CPU(cs);
|
||||
|
||||
if (!cpu->apic_state) {
|
||||
cpu_interrupt(cs, CPU_INTERRUPT_NMI);
|
||||
} else {
|
||||
apic_deliver_nmi(cpu->apic_state);
|
||||
}
|
||||
}
|
||||
#else
|
||||
nmi_monitor_handle(0, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
static const TypeInfo nmi_info = {
|
||||
.name = TYPE_NMI,
|
||||
.parent = TYPE_INTERFACE,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
common-obj-y += watchdog.o
|
||||
common-obj-$(CONFIG_WDT_IB6300ESB) += wdt_i6300esb.o
|
||||
common-obj-$(CONFIG_WDT_IB700) += wdt_ib700.o
|
||||
common-obj-$(CONFIG_WDT_DIAG288) += wdt_diag288.o
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "sysemu/sysemu.h"
|
||||
#include "sysemu/watchdog.h"
|
||||
#include "qapi-event.h"
|
||||
#include "hw/nmi.h"
|
||||
|
||||
/* Possible values for action parameter. */
|
||||
#define WDT_RESET 1 /* Hard reset. */
|
||||
|
@ -35,6 +36,7 @@
|
|||
#define WDT_PAUSE 4 /* Pause. */
|
||||
#define WDT_DEBUG 5 /* Prints a message and continues running. */
|
||||
#define WDT_NONE 6 /* Do nothing. */
|
||||
#define WDT_NMI 7 /* Inject nmi into the guest */
|
||||
|
||||
static int watchdog_action = WDT_RESET;
|
||||
static QLIST_HEAD(watchdog_list, WatchdogTimerModel) watchdog_list;
|
||||
|
@ -95,6 +97,8 @@ int select_watchdog_action(const char *p)
|
|||
watchdog_action = WDT_DEBUG;
|
||||
else if (strcasecmp(p, "none") == 0)
|
||||
watchdog_action = WDT_NONE;
|
||||
else if (strcasecmp(p, "inject-nmi") == 0)
|
||||
watchdog_action = WDT_NMI;
|
||||
else
|
||||
return -1;
|
||||
|
||||
|
@ -138,5 +142,11 @@ void watchdog_perform_action(void)
|
|||
case WDT_NONE:
|
||||
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_NONE, &error_abort);
|
||||
break;
|
||||
|
||||
case WDT_NMI:
|
||||
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_INJECT_NMI,
|
||||
&error_abort);
|
||||
inject_nmi();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
122
hw/watchdog/wdt_diag288.c
Normal file
122
hw/watchdog/wdt_diag288.c
Normal file
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* watchdog device diag288 support
|
||||
*
|
||||
* Copyright IBM, Corp. 2015
|
||||
*
|
||||
* Authors:
|
||||
* Xu Wang <gesaint@linux.vnet.ibm.com>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or (at your
|
||||
* option) any later version. See the COPYING file in the top-level directory.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "sysemu/watchdog.h"
|
||||
#include "hw/sysbus.h"
|
||||
#include "qemu/timer.h"
|
||||
#include "hw/watchdog/wdt_diag288.h"
|
||||
|
||||
static WatchdogTimerModel model = {
|
||||
.wdt_name = TYPE_WDT_DIAG288,
|
||||
.wdt_description = "diag288 device for s390x platform",
|
||||
};
|
||||
|
||||
static const VMStateDescription vmstate_diag288 = {
|
||||
.name = "vmstate_diag288",
|
||||
.version_id = 0,
|
||||
.minimum_version_id = 0,
|
||||
.fields = (VMStateField[]) {
|
||||
VMSTATE_TIMER_PTR(timer, DIAG288State),
|
||||
VMSTATE_BOOL(enabled, DIAG288State),
|
||||
VMSTATE_END_OF_LIST()
|
||||
}
|
||||
};
|
||||
|
||||
static void wdt_diag288_reset(DeviceState *dev)
|
||||
{
|
||||
DIAG288State *diag288 = DIAG288(dev);
|
||||
|
||||
diag288->enabled = false;
|
||||
timer_del(diag288->timer);
|
||||
}
|
||||
|
||||
static void diag288_timer_expired(void *dev)
|
||||
{
|
||||
qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n");
|
||||
watchdog_perform_action();
|
||||
wdt_diag288_reset(dev);
|
||||
}
|
||||
|
||||
static int wdt_diag288_handle_timer(DIAG288State *diag288,
|
||||
uint64_t func, uint64_t timeout)
|
||||
{
|
||||
switch (func) {
|
||||
case WDT_DIAG288_INIT:
|
||||
diag288->enabled = true;
|
||||
/* fall through */
|
||||
case WDT_DIAG288_CHANGE:
|
||||
if (!diag288->enabled) {
|
||||
return -1;
|
||||
}
|
||||
timer_mod(diag288->timer,
|
||||
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
|
||||
timeout * get_ticks_per_sec());
|
||||
break;
|
||||
case WDT_DIAG288_CANCEL:
|
||||
if (!diag288->enabled) {
|
||||
return -1;
|
||||
}
|
||||
diag288->enabled = false;
|
||||
timer_del(diag288->timer);
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void wdt_diag288_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
DIAG288State *diag288 = DIAG288(dev);
|
||||
|
||||
diag288->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, diag288_timer_expired,
|
||||
dev);
|
||||
}
|
||||
|
||||
static void wdt_diag288_unrealize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
DIAG288State *diag288 = DIAG288(dev);
|
||||
|
||||
timer_del(diag288->timer);
|
||||
timer_free(diag288->timer);
|
||||
}
|
||||
|
||||
static void wdt_diag288_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
DIAG288Class *diag288 = DIAG288_CLASS(klass);
|
||||
|
||||
dc->realize = wdt_diag288_realize;
|
||||
dc->unrealize = wdt_diag288_unrealize;
|
||||
dc->reset = wdt_diag288_reset;
|
||||
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
|
||||
dc->vmsd = &vmstate_diag288;
|
||||
diag288->handle_timer = wdt_diag288_handle_timer;
|
||||
}
|
||||
|
||||
static const TypeInfo wdt_diag288_info = {
|
||||
.class_init = wdt_diag288_class_init,
|
||||
.parent = TYPE_DEVICE,
|
||||
.name = TYPE_WDT_DIAG288,
|
||||
.instance_size = sizeof(DIAG288State),
|
||||
.class_size = sizeof(DIAG288Class),
|
||||
};
|
||||
|
||||
static void wdt_diag288_register_types(void)
|
||||
{
|
||||
watchdog_add_model(&model);
|
||||
type_register_static(&wdt_diag288_info);
|
||||
}
|
||||
|
||||
type_init(wdt_diag288_register_types)
|
Loading…
Add table
Add a link
Reference in a new issue