From: Scott Wood <scottwood@freescale.com>
To: kvm-ppc@vger.kernel.org
Subject: Re: [PATCH 3/3 v3] Enable kvm emulated watchdog
Date: Thu, 19 Jul 2012 02:33:40 +0000 [thread overview]
Message-ID: <50077204.3010401@freescale.com> (raw)
In-Reply-To: <1342611279-22868-1-git-send-email-Bharat.Bhushan@freescale.com>
On 07/18/2012 06:34 AM, Bharat Bhushan wrote:
> diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
> index 4b9e575..64d94da 100644
> --- a/linux-headers/linux/kvm.h
> +++ b/linux-headers/linux/kvm.h
> @@ -163,6 +163,7 @@ struct kvm_pit_config {
> #define KVM_EXIT_OSI 18
> #define KVM_EXIT_PAPR_HCALL 19
> #define KVM_EXIT_S390_UCONTROL 20
> +#define KVM_EXIT_WATCHDOG 21
>
> /* For KVM_EXIT_INTERNAL_ERROR */
> #define KVM_INTERNAL_ERROR_EMULATION 1
> @@ -618,6 +619,7 @@ struct kvm_ppc_smmu_info {
> #define KVM_CAP_PPC_GET_SMMU_INFO 78
> #define KVM_CAP_S390_COW 79
> #define KVM_CAP_PPC_ALLOC_HTAB 80
> +#define KVM_CAP_PPC_WDT 81
>
> #ifdef KVM_CAP_IRQ_ROUTING
>
linux headers update should be a separate patch.
> @@ -371,6 +393,33 @@ static inline void kvm_fixup_page_sizes(CPUPPCState *env)
>
> #endif /* !defined (TARGET_PPC64) */
>
> +static void cpu_state_change_handler(void *opaque, int running, RunState state)
> +{
> + CPUPPCState *env = opaque;
> +
> + struct kvm_sregs sregs;
> +
> + printf("running = %d, state = %d \n", running, state);
Remove this printf.
> + if (!running)
> + return;
> +
> + /*
> + * Clear watchdog interrupt condition by clearing TSR.
> + * Similar logic needed to be implemented for watchdog
> + * emulation in qemu.
> + */
> + if (cap_booke_sregs && cap_ppc_wdt) {
> + kvm_vcpu_ioctl(env, KVM_GET_SREGS, &sregs);
> +
> + /* Clear TSR.ENW, TSR.WIS and TSR.WRS */
> + ppc_booke_wdt_clear_tsr(env, sregs.u.e.tsr);
> + sregs.u.e.tsr = env->spr[SPR_BOOKE_TSR];
> + sregs.u.e.update_special = KVM_SREGS_E_BASE | KVM_SREGS_E_UPDATE_TSR;
KVM_SREGS_E_BASE is for "features", not "update_special". Used here
it'll translate to KVM_SREGS_E_UPDATE_MCSR.
> + kvm_vcpu_ioctl(env, KVM_SET_SREGS, &sregs);
> + }
> +}
> +
> int kvm_arch_init_vcpu(CPUPPCState *cenv)
> {
> int ret;
> @@ -384,6 +433,13 @@ int kvm_arch_init_vcpu(CPUPPCState *cenv)
> return ret;
> }
>
> + ret = kvm_wdt_enable(cenv);
> + if (ret) {
> + return ret;
> + }
s/wdt/watchdog/g
Only do this if the user asks for a watchdog enforcement action -- and
if they do, make sure to at least warn if KVM doesn't support it.
> + qemu_add_vm_change_state_handler(cpu_state_change_handler, cenv);
> +
> idle_timer = qemu_new_timer_ns(vm_clock, kvm_kick_env, cenv);
>
> /* Some targets support access to KVM's guest TLB. */
> @@ -769,6 +825,13 @@ int kvm_arch_handle_exit(CPUPPCState *env, struct kvm_run *run)
> ret = 1;
> break;
> #endif
> +#ifdef KVM_EXIT_WATCHDOG
> + case KVM_EXIT_WATCHDOG:
> + dprintf("booke watchdog action\n");
> + watchdog_perform_action();
> + ret = 0;
> + break;
Indentation. Is this part really booke-specific?
-Scott
prev parent reply other threads:[~2012-07-19 2:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-18 11:46 [PATCH 3/3 v3] Enable kvm emulated watchdog Bharat Bhushan
2012-07-19 2:33 ` Scott Wood [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50077204.3010401@freescale.com \
--to=scottwood@freescale.com \
--cc=kvm-ppc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox