Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: KVM: Use cacheops.h definitions

Drop the custom cache operation code definitions used by KVM for
emulating guest CACHE instructions, and switch to use the existing
definitions in <asm/cacheops.h>.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Gleb Natapov <gleb@kernel.org>
Cc: kvm@vger.kernel.org
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/11893/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

James Hogan and committed by
Ralf Baechle
f4956f62 5fa393c8

+8 -22
+8 -22
arch/mips/kvm/emulate.c
··· 20 20 #include <linux/random.h> 21 21 #include <asm/page.h> 22 22 #include <asm/cacheflush.h> 23 + #include <asm/cacheops.h> 23 24 #include <asm/cpu-info.h> 24 25 #include <asm/mmu_context.h> 25 26 #include <asm/tlbflush.h> ··· 1545 1544 return 0; 1546 1545 } 1547 1546 1548 - #define MIPS_CACHE_OP_INDEX_INV 0x0 1549 - #define MIPS_CACHE_OP_INDEX_LD_TAG 0x1 1550 - #define MIPS_CACHE_OP_INDEX_ST_TAG 0x2 1551 - #define MIPS_CACHE_OP_IMP 0x3 1552 - #define MIPS_CACHE_OP_HIT_INV 0x4 1553 - #define MIPS_CACHE_OP_FILL_WB_INV 0x5 1554 - #define MIPS_CACHE_OP_HIT_HB 0x6 1555 - #define MIPS_CACHE_OP_FETCH_LOCK 0x7 1556 - 1557 - #define MIPS_CACHE_ICACHE 0x0 1558 - #define MIPS_CACHE_DCACHE 0x1 1559 - #define MIPS_CACHE_SEC 0x3 1560 - 1561 1547 enum emulation_result kvm_mips_emulate_cache(uint32_t inst, uint32_t *opc, 1562 1548 uint32_t cause, 1563 1549 struct kvm_run *run, ··· 1569 1581 base = (inst >> 21) & 0x1f; 1570 1582 op_inst = (inst >> 16) & 0x1f; 1571 1583 offset = (int16_t)inst; 1572 - cache = (inst >> 16) & 0x3; 1573 - op = (inst >> 18) & 0x7; 1584 + cache = op_inst & CacheOp_Cache; 1585 + op = op_inst & CacheOp_Op; 1574 1586 1575 1587 va = arch->gprs[base] + offset; 1576 1588 ··· 1582 1594 * invalidate the caches entirely by stepping through all the 1583 1595 * ways/indexes 1584 1596 */ 1585 - if (op == MIPS_CACHE_OP_INDEX_INV) { 1597 + if (op == Index_Writeback_Inv) { 1586 1598 kvm_debug("@ %#lx/%#lx CACHE (cache: %#x, op: %#x, base[%d]: %#lx, offset: %#x\n", 1587 1599 vcpu->arch.pc, vcpu->arch.gprs[31], cache, op, base, 1588 1600 arch->gprs[base], offset); 1589 1601 1590 - if (cache == MIPS_CACHE_DCACHE) 1602 + if (cache == Cache_D) 1591 1603 r4k_blast_dcache(); 1592 - else if (cache == MIPS_CACHE_ICACHE) 1604 + else if (cache == Cache_I) 1593 1605 r4k_blast_icache(); 1594 1606 else { 1595 1607 kvm_err("%s: unsupported CACHE INDEX operation\n", ··· 1662 1674 1663 1675 skip_fault: 1664 1676 /* XXXKYMA: Only a subset of cache ops are supported, used by Linux */ 1665 - if (cache == MIPS_CACHE_DCACHE 1666 - && (op == MIPS_CACHE_OP_FILL_WB_INV 1667 - || op == MIPS_CACHE_OP_HIT_INV)) { 1677 + if (op_inst == Hit_Writeback_Inv_D || op_inst == Hit_Invalidate_D) { 1668 1678 flush_dcache_line(va); 1669 1679 1670 1680 #ifdef CONFIG_KVM_MIPS_DYN_TRANS ··· 1672 1686 */ 1673 1687 kvm_mips_trans_cache_va(inst, opc, vcpu); 1674 1688 #endif 1675 - } else if (op == MIPS_CACHE_OP_HIT_INV && cache == MIPS_CACHE_ICACHE) { 1689 + } else if (op_inst == Hit_Invalidate_I) { 1676 1690 flush_dcache_line(va); 1677 1691 flush_icache_line(va); 1678 1692