* ========== Copyright Header Begin ==========================================
* Hypervisor Software File: heartbeat.s
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* - Do no alter or remove copyright notices
* - Redistribution and use of this software in source and binary forms, with
* or without modification, are permitted provided that the following
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
* MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
* OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
* FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* You acknowledge that this software is not designed, licensed or
* intended for use in the design, construction, operation or maintenance of
* ========== Copyright Header End ============================================
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
.ident "@(#)heartbeat.s 1.6 07/05/03 SMI"
#include <sys/asm_linkage.h>
* heartbeat - recurring hypervisor heartbeat
CPU_PUSH(%g7, %g2, %g3, %g4)
ldx [%g2 + CONFIG_HEARTBEAT_CPU], %g3
be,pn %xcc, .heartbeat_exit
HVCALL(heartbeat_watchdog)
* Schedule the next timeout
CPU_POP(%g7, %g2, %g3, %g4)
* heartbeat_watchdog - check for guest watchdog timer expirations
ENTRY_NP(heartbeat_watchdog)
* FIXME: Only update the watchdog timer for the control
* domain. Eventually, this will need to be made aware
CTRL_DOMAIN(%g1, %g2, %g3)
!! %g1 = control domain guestp
set GUEST_WATCHDOG + WATCHDOG_TICKS, %g2
brz,pt %g3, 1f ! zero value is disabled
/* Decrement counter, new value of zero is watchdog expiry */
ATOMIC_ADD_64(%g2, -1, %g3, %g4)
mov %g7, %g5 ! %g7 holds the %pc for HVRET
PRINT_NOTRAP("guest watchdog timer expiry\r\n")
mov %g5, %g7 ! restore %g7 for HVRET
#if defined(CONFIG_VBSC_SVC)
ba,pt %xcc, vbsc_guest_wdexpire ! tail call returns to caller
/* only get here when no CONFIG_VBSC_SVC or no expiration */
SET_SIZE(heartbeat_watchdog)
* heartbeat_enable - schedule the next heartbeat
ENTRY_NP(heartbeat_enable)
STRAND2CONFIG_STRUCT(%g6, %g5)
ldub [%g6 + STRAND_ID], %g3
stx %g3, [%g5 + CONFIG_HEARTBEAT_CPU]
ldx [%g5 + CONFIG_STICKFREQUENCY], %g1 ! interval: 1sec
ldx [%g5 + CONFIG_RELOC], %g4
sub %g2, %g4, %g2 ! handler: guest_watchdog_handler
ba,a cyclic_add_rel ! (void), tail call
SET_SIZE(heartbeat_enable)
* heartbeat_disable - cancel pending heartbeats
ENTRY_NP(heartbeat_disable)
STRAND2CONFIG_STRUCT(%g1, %g2)
* We can only disable the heartbeat on the cpu it's running on.
ldub [%g1 + STRAND_ID], %g3
ldx [%g2 + CONFIG_HEARTBEAT_CPU], %g4
* Mark that there is no heartbeat cpu
stx %g3, [%g2 + CONFIG_HEARTBEAT_CPU]
* Cancel future heartbeats
ldx [%g2 + CONFIG_RELOC], %g1
sub %g2, %g1, %g2 ! handler: guest_watchdog_handler
ba,a cyclic_remove ! tail-call
SET_SIZE(heartbeat_disable)