xref: /illumos-gate/usr/src/uts/intel/io/vmm/amd/svm_msr.h (revision 32640292)
14c87aefeSPatrick Mooney /*-
2*32640292SAndy Fiddaman  * SPDX-License-Identifier: BSD-2-Clause
34c87aefeSPatrick Mooney  *
44c87aefeSPatrick Mooney  * Copyright (c) 2014 Neel Natu (neel@freebsd.org)
54c87aefeSPatrick Mooney  * All rights reserved.
64c87aefeSPatrick Mooney  *
74c87aefeSPatrick Mooney  * Redistribution and use in source and binary forms, with or without
84c87aefeSPatrick Mooney  * modification, are permitted provided that the following conditions
94c87aefeSPatrick Mooney  * are met:
104c87aefeSPatrick Mooney  * 1. Redistributions of source code must retain the above copyright
114c87aefeSPatrick Mooney  *    notice unmodified, this list of conditions, and the following
124c87aefeSPatrick Mooney  *    disclaimer.
134c87aefeSPatrick Mooney  * 2. Redistributions in binary form must reproduce the above copyright
144c87aefeSPatrick Mooney  *    notice, this list of conditions and the following disclaimer in the
154c87aefeSPatrick Mooney  *    documentation and/or other materials provided with the distribution.
164c87aefeSPatrick Mooney  *
174c87aefeSPatrick Mooney  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
184c87aefeSPatrick Mooney  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
194c87aefeSPatrick Mooney  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
204c87aefeSPatrick Mooney  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
214c87aefeSPatrick Mooney  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
224c87aefeSPatrick Mooney  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
234c87aefeSPatrick Mooney  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
244c87aefeSPatrick Mooney  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
254c87aefeSPatrick Mooney  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
264c87aefeSPatrick Mooney  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
274c87aefeSPatrick Mooney  */
284c87aefeSPatrick Mooney 
294c87aefeSPatrick Mooney #ifndef _SVM_MSR_H_
304c87aefeSPatrick Mooney #define	_SVM_MSR_H_
314c87aefeSPatrick Mooney 
324c87aefeSPatrick Mooney struct svm_softc;
334c87aefeSPatrick Mooney 
344c87aefeSPatrick Mooney void svm_msr_guest_init(struct svm_softc *sc, int vcpu);
354c87aefeSPatrick Mooney void svm_msr_guest_enter(struct svm_softc *sc, int vcpu);
364c87aefeSPatrick Mooney void svm_msr_guest_exit(struct svm_softc *sc, int vcpu);
374c87aefeSPatrick Mooney 
38d2f938fdSPatrick Mooney vm_msr_result_t svm_wrmsr(struct svm_softc *, int, uint32_t, uint64_t);
39d2f938fdSPatrick Mooney vm_msr_result_t svm_rdmsr(struct svm_softc *, int, uint32_t, uint64_t *);
404c87aefeSPatrick Mooney 
41717646f7SJordan Paige Hendricks /*
42717646f7SJordan Paige Hendricks  * TSC Frequency Multiplier MSR related values
43717646f7SJordan Paige Hendricks  */
44717646f7SJordan Paige Hendricks 
45717646f7SJordan Paige Hendricks /* N integer bits of frequency multiplier */
46717646f7SJordan Paige Hendricks #define	AMD_TSCM_INT_SIZE	8
47717646f7SJordan Paige Hendricks 
48717646f7SJordan Paige Hendricks /* N fractional bits of frequency multiplier */
49717646f7SJordan Paige Hendricks #define	AMD_TSCM_FRAC_SIZE	32
50717646f7SJordan Paige Hendricks 
51717646f7SJordan Paige Hendricks /*
52717646f7SJordan Paige Hendricks  * The reset value of the frequency multiplier is 1.0 (section 15.30.5 of AMD
53717646f7SJordan Paige Hendricks  * Architecture Programmer's Manual Volume 2), indicating the host and guest
54717646f7SJordan Paige Hendricks  * have the same TSC frequency.
55717646f7SJordan Paige Hendricks  */
56717646f7SJordan Paige Hendricks #define	AMD_TSCM_RESET_VAL	(1ULL << AMD_TSCM_FRAC_SIZE)
57717646f7SJordan Paige Hendricks 
584c87aefeSPatrick Mooney #endif	/* _SVM_MSR_H_ */
59