summaryrefslogtreecommitdiffstats
path: root/target-s390x
diff options
context:
space:
mode:
Diffstat (limited to 'target-s390x')
-rw-r--r--target-s390x/cpu.h66
-rw-r--r--target-s390x/interrupt.c56
-rw-r--r--target-s390x/kvm.c275
-rw-r--r--target-s390x/misc_helper.c9
4 files changed, 308 insertions, 98 deletions
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 06454d6..b13761d 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -357,30 +357,23 @@ void s390x_tod_timer(void *opaque);
void s390x_cpu_timer(void *opaque);
int s390_virtio_hypercall(CPUS390XState *env);
+void s390_virtio_irq(int config_change, uint64_t token);
#ifdef CONFIG_KVM
void kvm_s390_reset_vcpu(S390CPU *cpu);
-void kvm_s390_interrupt(S390CPU *cpu, int type, uint32_t code);
-void kvm_s390_virtio_irq(S390CPU *cpu, int config_change, uint64_t token);
-void kvm_s390_interrupt_internal(S390CPU *cpu, int type, uint32_t parm,
- uint64_t parm64, int vm);
+void kvm_s390_virtio_irq(int config_change, uint64_t token);
+void kvm_s390_service_interrupt(uint32_t parm);
+void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq);
+void kvm_s390_floating_interrupt(struct kvm_s390_irq *irq);
+int kvm_s390_inject_flic(struct kvm_s390_irq *irq);
#else
static inline void kvm_s390_reset_vcpu(S390CPU *cpu)
{
}
-
-static inline void kvm_s390_interrupt(S390CPU *cpu, int type, uint32_t code)
+static inline void kvm_s390_virtio_irq(int config_change, uint64_t token)
{
}
-
-static inline void kvm_s390_virtio_irq(S390CPU *cpu, int config_change,
- uint64_t token)
-{
-}
-
-static inline void kvm_s390_interrupt_internal(S390CPU *cpu, int type,
- uint32_t parm, uint64_t parm64,
- int vm)
+static inline void kvm_s390_service_interrupt(uint32_t parm)
{
}
#endif
@@ -1066,23 +1059,23 @@ void QEMU_NORETURN runtime_exception(CPUS390XState *env, int excp,
uintptr_t retaddr);
#ifdef CONFIG_KVM
-void kvm_s390_io_interrupt(S390CPU *cpu, uint16_t subchannel_id,
+void kvm_s390_io_interrupt(uint16_t subchannel_id,
uint16_t subchannel_nr, uint32_t io_int_parm,
uint32_t io_int_word);
-void kvm_s390_crw_mchk(S390CPU *cpu);
+void kvm_s390_crw_mchk(void);
void kvm_s390_enable_css_support(S390CPU *cpu);
int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch,
int vq, bool assign);
int kvm_s390_cpu_restart(S390CPU *cpu);
+void kvm_s390_clear_cmma_callback(void *opaque);
#else
-static inline void kvm_s390_io_interrupt(S390CPU *cpu,
- uint16_t subchannel_id,
+static inline void kvm_s390_io_interrupt(uint16_t subchannel_id,
uint16_t subchannel_nr,
uint32_t io_int_parm,
uint32_t io_int_word)
{
}
-static inline void kvm_s390_crw_mchk(S390CPU *cpu)
+static inline void kvm_s390_crw_mchk(void)
{
}
static inline void kvm_s390_enable_css_support(S390CPU *cpu)
@@ -1098,40 +1091,31 @@ static inline int kvm_s390_cpu_restart(S390CPU *cpu)
{
return -ENOSYS;
}
-#endif
-
-static inline int s390_cpu_restart(S390CPU *cpu)
+static inline void kvm_s390_clear_cmma_callback(void *opaque)
{
- if (kvm_enabled()) {
- return kvm_s390_cpu_restart(cpu);
- }
- return -ENOSYS;
}
+#endif
-static inline void s390_io_interrupt(S390CPU *cpu,
- uint16_t subchannel_id,
- uint16_t subchannel_nr,
- uint32_t io_int_parm,
- uint32_t io_int_word)
+static inline void cmma_reset(S390CPU *cpu)
{
if (kvm_enabled()) {
- kvm_s390_io_interrupt(cpu, subchannel_id, subchannel_nr, io_int_parm,
- io_int_word);
- } else {
- cpu_inject_io(cpu, subchannel_id, subchannel_nr, io_int_parm,
- io_int_word);
+ CPUState *cs = CPU(cpu);
+ kvm_s390_clear_cmma_callback(cs->kvm_state);
}
}
-static inline void s390_crw_mchk(S390CPU *cpu)
+static inline int s390_cpu_restart(S390CPU *cpu)
{
if (kvm_enabled()) {
- kvm_s390_crw_mchk(cpu);
- } else {
- cpu_inject_crw_mchk(cpu);
+ return kvm_s390_cpu_restart(cpu);
}
+ return -ENOSYS;
}
+void s390_io_interrupt(uint16_t subchannel_id, uint16_t subchannel_nr,
+ uint32_t io_int_parm, uint32_t io_int_word);
+void s390_crw_mchk(void);
+
static inline int s390_assign_subch_ioeventfd(EventNotifier *notifier,
uint32_t sch_id, int vq,
bool assign)
diff --git a/target-s390x/interrupt.c b/target-s390x/interrupt.c
index 6d6580d..23a9114 100644
--- a/target-s390x/interrupt.c
+++ b/target-s390x/interrupt.c
@@ -1,7 +1,7 @@
/*
* QEMU S/390 Interrupt support
*
- * Copyright IBM, Corp. 2012
+ * Copyright IBM Corp. 2012, 2014
*
* 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.
@@ -10,21 +10,59 @@
#include "cpu.h"
#include "sysemu/kvm.h"
+/*
+ * All of the following interrupts are floating, i.e. not per-vcpu.
+ * We just need a dummy cpustate in order to be able to inject in the
+ * non-kvm case.
+ */
#if !defined(CONFIG_USER_ONLY)
-/* service interrupts are floating therefore we must not pass an cpustate */
void s390_sclp_extint(uint32_t parm)
{
- S390CPU *dummy_cpu = s390_cpu_addr2state(0);
- CPUS390XState *env = &dummy_cpu->env;
-
if (kvm_enabled()) {
-#ifdef CONFIG_KVM
- kvm_s390_interrupt_internal(dummy_cpu, KVM_S390_INT_SERVICE, parm,
- 0, 1);
-#endif
+ kvm_s390_service_interrupt(parm);
} else {
+ S390CPU *dummy_cpu = s390_cpu_addr2state(0);
+ CPUS390XState *env = &dummy_cpu->env;
+
env->psw.addr += 4;
cpu_inject_ext(dummy_cpu, EXT_SERVICE, parm, 0);
}
}
+
+void s390_virtio_irq(int config_change, uint64_t token)
+{
+ if (kvm_enabled()) {
+ kvm_s390_virtio_irq(config_change, token);
+ } else {
+ S390CPU *dummy_cpu = s390_cpu_addr2state(0);
+
+ cpu_inject_ext(dummy_cpu, EXT_VIRTIO, config_change, token);
+ }
+}
+
+void s390_io_interrupt(uint16_t subchannel_id, uint16_t subchannel_nr,
+ uint32_t io_int_parm, uint32_t io_int_word)
+{
+ if (kvm_enabled()) {
+ kvm_s390_io_interrupt(subchannel_id, subchannel_nr, io_int_parm,
+ io_int_word);
+ } else {
+ S390CPU *dummy_cpu = s390_cpu_addr2state(0);
+
+ cpu_inject_io(dummy_cpu, subchannel_id, subchannel_nr, io_int_parm,
+ io_int_word);
+ }
+}
+
+void s390_crw_mchk(void)
+{
+ if (kvm_enabled()) {
+ kvm_s390_crw_mchk();
+ } else {
+ S390CPU *dummy_cpu = s390_cpu_addr2state(0);
+
+ cpu_inject_crw_mchk(dummy_cpu);
+ }
+}
+
#endif
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 7a07f9d..a1a4cc2 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -32,6 +32,7 @@
#include "qemu/timer.h"
#include "sysemu/sysemu.h"
#include "sysemu/kvm.h"
+#include "hw/hw.h"
#include "cpu.h"
#include "sysemu/device_tree.h"
#include "qapi/qmp/qjson.h"
@@ -82,6 +83,8 @@
#define DIAG_KVM_BREAKPOINT 0x501
#define ICPT_INSTRUCTION 0x04
+#define ICPT_PROGRAM 0x08
+#define ICPT_EXT_INT 0x14
#define ICPT_WAITPSW 0x1c
#define ICPT_SOFT_INTERCEPT 0x24
#define ICPT_CPU_STOP 0x28
@@ -104,10 +107,67 @@ static int cap_async_pf;
static void *legacy_s390_alloc(size_t size);
+static int kvm_s390_check_clear_cmma(KVMState *s)
+{
+ struct kvm_device_attr attr = {
+ .group = KVM_S390_VM_MEM_CTRL,
+ .attr = KVM_S390_VM_MEM_CLR_CMMA,
+ };
+
+ return kvm_vm_ioctl(s, KVM_HAS_DEVICE_ATTR, &attr);
+}
+
+static int kvm_s390_check_enable_cmma(KVMState *s)
+{
+ struct kvm_device_attr attr = {
+ .group = KVM_S390_VM_MEM_CTRL,
+ .attr = KVM_S390_VM_MEM_ENABLE_CMMA,
+ };
+
+ return kvm_vm_ioctl(s, KVM_HAS_DEVICE_ATTR, &attr);
+}
+
+void kvm_s390_clear_cmma_callback(void *opaque)
+{
+ int rc;
+ KVMState *s = opaque;
+ struct kvm_device_attr attr = {
+ .group = KVM_S390_VM_MEM_CTRL,
+ .attr = KVM_S390_VM_MEM_CLR_CMMA,
+ };
+
+ rc = kvm_vm_ioctl(s, KVM_SET_DEVICE_ATTR, &attr);
+ trace_kvm_clear_cmma(rc);
+}
+
+static void kvm_s390_enable_cmma(KVMState *s)
+{
+ int rc;
+ struct kvm_device_attr attr = {
+ .group = KVM_S390_VM_MEM_CTRL,
+ .attr = KVM_S390_VM_MEM_ENABLE_CMMA,
+ };
+
+ if (kvm_s390_check_enable_cmma(s) || kvm_s390_check_clear_cmma(s)) {
+ return;
+ }
+
+ rc = kvm_vm_ioctl(s, KVM_SET_DEVICE_ATTR, &attr);
+ if (!rc) {
+ qemu_register_reset(kvm_s390_clear_cmma_callback, s);
+ }
+ trace_kvm_enable_cmma(rc);
+}
+
int kvm_arch_init(KVMState *s)
{
cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF);
+
+ if (kvm_check_extension(s, KVM_CAP_VM_ATTRIBUTES)) {
+ kvm_s390_enable_cmma(s);
+ }
+
if (!kvm_check_extension(s, KVM_CAP_S390_GMAP)
|| !kvm_check_extension(s, KVM_CAP_S390_COW)) {
phys_mem_set_alloc(legacy_s390_alloc);
@@ -495,47 +555,138 @@ int kvm_arch_process_async_events(CPUState *cs)
return cs->halted;
}
-void kvm_s390_interrupt_internal(S390CPU *cpu, int type, uint32_t parm,
- uint64_t parm64, int vm)
+static int s390_kvm_irq_to_interrupt(struct kvm_s390_irq *irq,
+ struct kvm_s390_interrupt *interrupt)
{
+ int r = 0;
+
+ interrupt->type = irq->type;
+ switch (irq->type) {
+ case KVM_S390_INT_VIRTIO:
+ interrupt->parm = irq->u.ext.ext_params;
+ /* fall through */
+ case KVM_S390_INT_PFAULT_INIT:
+ case KVM_S390_INT_PFAULT_DONE:
+ interrupt->parm64 = irq->u.ext.ext_params2;
+ break;
+ case KVM_S390_PROGRAM_INT:
+ interrupt->parm = irq->u.pgm.code;
+ break;
+ case KVM_S390_SIGP_SET_PREFIX:
+ interrupt->parm = irq->u.prefix.address;
+ break;
+ case KVM_S390_INT_SERVICE:
+ interrupt->parm = irq->u.ext.ext_params;
+ break;
+ case KVM_S390_MCHK:
+ interrupt->parm = irq->u.mchk.cr14;
+ interrupt->parm64 = irq->u.mchk.mcic;
+ break;
+ case KVM_S390_INT_EXTERNAL_CALL:
+ interrupt->parm = irq->u.extcall.code;
+ break;
+ case KVM_S390_INT_EMERGENCY:
+ interrupt->parm = irq->u.emerg.code;
+ break;
+ case KVM_S390_SIGP_STOP:
+ case KVM_S390_RESTART:
+ break; /* These types have no parameters */
+ case KVM_S390_INT_IO_MIN...KVM_S390_INT_IO_MAX:
+ interrupt->parm = irq->u.io.subchannel_id << 16;
+ interrupt->parm |= irq->u.io.subchannel_nr;
+ interrupt->parm64 = (uint64_t)irq->u.io.io_int_parm << 32;
+ interrupt->parm64 |= irq->u.io.io_int_word;
+ break;
+ default:
+ r = -EINVAL;
+ break;
+ }
+ return r;
+}
+
+void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq)
+{
+ struct kvm_s390_interrupt kvmint = {};
CPUState *cs = CPU(cpu);
- struct kvm_s390_interrupt kvmint;
int r;
- if (!cs->kvm_state) {
- return;
+ r = s390_kvm_irq_to_interrupt(irq, &kvmint);
+ if (r < 0) {
+ fprintf(stderr, "%s called with bogus interrupt\n", __func__);
+ exit(1);
+ }
+
+ r = kvm_vcpu_ioctl(cs, KVM_S390_INTERRUPT, &kvmint);
+ if (r < 0) {
+ fprintf(stderr, "KVM failed to inject interrupt\n");
+ exit(1);
}
+}
- kvmint.type = type;
- kvmint.parm = parm;
- kvmint.parm64 = parm64;
+static void __kvm_s390_floating_interrupt(struct kvm_s390_irq *irq)
+{
+ struct kvm_s390_interrupt kvmint = {};
+ int r;
- if (vm) {
- r = kvm_vm_ioctl(cs->kvm_state, KVM_S390_INTERRUPT, &kvmint);
- } else {
- r = kvm_vcpu_ioctl(cs, KVM_S390_INTERRUPT, &kvmint);
+ r = s390_kvm_irq_to_interrupt(irq, &kvmint);
+ if (r < 0) {
+ fprintf(stderr, "%s called with bogus interrupt\n", __func__);
+ exit(1);
}
+ r = kvm_vm_ioctl(kvm_state, KVM_S390_INTERRUPT, &kvmint);
if (r < 0) {
fprintf(stderr, "KVM failed to inject interrupt\n");
exit(1);
}
}
-void kvm_s390_virtio_irq(S390CPU *cpu, int config_change, uint64_t token)
+void kvm_s390_floating_interrupt(struct kvm_s390_irq *irq)
{
- kvm_s390_interrupt_internal(cpu, KVM_S390_INT_VIRTIO, config_change,
- token, 1);
+ static bool use_flic = true;
+ int r;
+
+ if (use_flic) {
+ r = kvm_s390_inject_flic(irq);
+ if (r == -ENOSYS) {
+ use_flic = false;
+ }
+ if (!r) {
+ return;
+ }
+ }
+ __kvm_s390_floating_interrupt(irq);
}
-void kvm_s390_interrupt(S390CPU *cpu, int type, uint32_t code)
+void kvm_s390_virtio_irq(int config_change, uint64_t token)
{
- kvm_s390_interrupt_internal(cpu, type, code, 0, 0);
+ struct kvm_s390_irq irq = {
+ .type = KVM_S390_INT_VIRTIO,
+ .u.ext.ext_params = config_change,
+ .u.ext.ext_params2 = token,
+ };
+
+ kvm_s390_floating_interrupt(&irq);
+}
+
+void kvm_s390_service_interrupt(uint32_t parm)
+{
+ struct kvm_s390_irq irq = {
+ .type = KVM_S390_INT_SERVICE,
+ .u.ext.ext_params = parm,
+ };
+
+ kvm_s390_floating_interrupt(&irq);
}
static void enter_pgmcheck(S390CPU *cpu, uint16_t code)
{
- kvm_s390_interrupt(cpu, KVM_S390_PROGRAM_INT, code);
+ struct kvm_s390_irq irq = {
+ .type = KVM_S390_PROGRAM_INT,
+ .u.pgm.code = code,
+ };
+
+ kvm_s390_vcpu_interrupt(cpu, &irq);
}
static int kvm_sclp_service_call(S390CPU *cpu, struct kvm_run *run,
@@ -751,7 +902,11 @@ static int kvm_s390_cpu_start(S390CPU *cpu)
int kvm_s390_cpu_restart(S390CPU *cpu)
{
- kvm_s390_interrupt(cpu, KVM_S390_RESTART, 0);
+ struct kvm_s390_irq irq = {
+ .type = KVM_S390_RESTART,
+ };
+
+ kvm_s390_vcpu_interrupt(cpu, &irq);
s390_add_running_cpu(cpu);
qemu_cpu_kick(CPU(cpu));
DPRINTF("DONE: KVM cpu restart: %p\n", &cpu->env);
@@ -872,6 +1027,28 @@ static bool is_special_wait_psw(CPUState *cs)
return cs->kvm_run->psw_addr == 0xfffUL;
}
+static void guest_panicked(void)
+{
+ QObject *data;
+
+ data = qobject_from_jsonf("{ 'action': %s }", "pause");
+ monitor_protocol_event(QEVENT_GUEST_PANICKED, data);
+ qobject_decref(data);
+
+ vm_stop(RUN_STATE_GUEST_PANICKED);
+}
+
+static void unmanageable_intercept(S390CPU *cpu, const char *str, int pswoffset)
+{
+ CPUState *cs = CPU(cpu);
+
+ error_report("Unmanageable %s! CPU%i new PSW: 0x%016lx:%016lx",
+ str, cs->cpu_index, ldq_phys(cs->as, cpu->env.psa + pswoffset),
+ ldq_phys(cs->as, cpu->env.psa + pswoffset + 8));
+ s390_del_running_cpu(cpu);
+ guest_panicked();
+}
+
static int handle_intercept(S390CPU *cpu)
{
CPUState *cs = CPU(cpu);
@@ -885,18 +1062,23 @@ static int handle_intercept(S390CPU *cpu)
case ICPT_INSTRUCTION:
r = handle_instruction(cpu, run);
break;
+ case ICPT_PROGRAM:
+ unmanageable_intercept(cpu, "program interrupt",
+ offsetof(LowCore, program_new_psw));
+ r = EXCP_HALTED;
+ break;
+ case ICPT_EXT_INT:
+ unmanageable_intercept(cpu, "external interrupt",
+ offsetof(LowCore, external_new_psw));
+ r = EXCP_HALTED;
+ break;
case ICPT_WAITPSW:
/* disabled wait, since enabled wait is handled in kernel */
if (s390_del_running_cpu(cpu) == 0) {
if (is_special_wait_psw(cs)) {
qemu_system_shutdown_request();
} else {
- QObject *data;
-
- data = qobject_from_jsonf("{ 'action': %s }", "pause");
- monitor_protocol_event(QEVENT_GUEST_PANICKED, data);
- qobject_decref(data);
- vm_stop(RUN_STATE_GUEST_PANICKED);
+ guest_panicked();
}
}
r = EXCP_HALTED;
@@ -944,18 +1126,10 @@ static int handle_tsch(S390CPU *cpu)
* If an I/O interrupt had been dequeued, we have to reinject it.
*/
if (run->s390_tsch.dequeued) {
- uint16_t subchannel_id = run->s390_tsch.subchannel_id;
- uint16_t subchannel_nr = run->s390_tsch.subchannel_nr;
- uint32_t io_int_parm = run->s390_tsch.io_int_parm;
- uint32_t io_int_word = run->s390_tsch.io_int_word;
- uint32_t type = ((subchannel_id & 0xff00) << 24) |
- ((subchannel_id & 0x00060) << 22) | (subchannel_nr << 16);
-
- kvm_s390_interrupt_internal(cpu, type,
- ((uint32_t)subchannel_id << 16)
- | subchannel_nr,
- ((uint64_t)io_int_parm << 32)
- | io_int_word, 1);
+ kvm_s390_io_interrupt(run->s390_tsch.subchannel_id,
+ run->s390_tsch.subchannel_nr,
+ run->s390_tsch.io_int_parm,
+ run->s390_tsch.io_int_word);
}
ret = 0;
}
@@ -1040,27 +1214,34 @@ int kvm_arch_on_sigbus(int code, void *addr)
return 1;
}
-void kvm_s390_io_interrupt(S390CPU *cpu, uint16_t subchannel_id,
+void kvm_s390_io_interrupt(uint16_t subchannel_id,
uint16_t subchannel_nr, uint32_t io_int_parm,
uint32_t io_int_word)
{
- uint32_t type;
+ struct kvm_s390_irq irq = {
+ .u.io.subchannel_id = subchannel_id,
+ .u.io.subchannel_nr = subchannel_nr,
+ .u.io.io_int_parm = io_int_parm,
+ .u.io.io_int_word = io_int_word,
+ };
if (io_int_word & IO_INT_WORD_AI) {
- type = KVM_S390_INT_IO(1, 0, 0, 0);
+ irq.type = KVM_S390_INT_IO(1, 0, 0, 0);
} else {
- type = ((subchannel_id & 0xff00) << 24) |
+ irq.type = ((subchannel_id & 0xff00) << 24) |
((subchannel_id & 0x00060) << 22) | (subchannel_nr << 16);
}
- kvm_s390_interrupt_internal(cpu, type,
- ((uint32_t)subchannel_id << 16) | subchannel_nr,
- ((uint64_t)io_int_parm << 32) | io_int_word, 1);
+ kvm_s390_floating_interrupt(&irq);
}
-void kvm_s390_crw_mchk(S390CPU *cpu)
+void kvm_s390_crw_mchk(void)
{
- kvm_s390_interrupt_internal(cpu, KVM_S390_MCHK, 1 << 28,
- 0x00400f1d40330000, 1);
+ struct kvm_s390_irq irq = {
+ .type = KVM_S390_MCHK,
+ .u.mchk.cr14 = 1 << 28,
+ .u.mchk.mcic = 0x00400f1d40330000,
+ };
+ kvm_s390_floating_interrupt(&irq);
}
void kvm_s390_enable_css_support(S390CPU *cpu)
diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c
index 9dae025..0b62582 100644
--- a/target-s390x/misc_helper.c
+++ b/target-s390x/misc_helper.c
@@ -85,7 +85,12 @@ void program_interrupt(CPUS390XState *env, uint32_t code, int ilen)
if (kvm_enabled()) {
#ifdef CONFIG_KVM
- kvm_s390_interrupt(cpu, KVM_S390_PROGRAM_INT, code);
+ struct kvm_s390_irq irq = {
+ .type = KVM_S390_PROGRAM_INT,
+ .u.pgm.code = code,
+ };
+
+ kvm_s390_vcpu_interrupt(cpu, &irq);
#endif
} else {
CPUState *cs = CPU(cpu);
@@ -136,6 +141,7 @@ static int modified_clear_reset(S390CPU *cpu)
pause_all_vcpus();
cpu_synchronize_all_states();
cpu_full_reset_all();
+ cmma_reset(cpu);
io_subsystem_reset();
scc->load_normal(CPU(cpu));
cpu_synchronize_all_post_reset();
@@ -150,6 +156,7 @@ static int load_normal_reset(S390CPU *cpu)
pause_all_vcpus();
cpu_synchronize_all_states();
cpu_reset_all();
+ cmma_reset(cpu);
io_subsystem_reset();
scc->initial_cpu_reset(CPU(cpu));
scc->load_normal(CPU(cpu));
OpenPOWER on IntegriCloud