Short answer: using logs won't really help. Instead, you should multiply $p$ by something large so that matlab can deal with it, and then divide out in the end.
Long answer:There is a $\log$ for matrices, but it doesn't behave quite the same as $\log$ for numbers, and so it's not quite suitable for computations in the way you think it is.
From Taylor series, we have that $e^x=\sum x^n/n!$ and $\log(1+x)=\sum (-1)^n x^{n+1}/(n+1)$. The fist formula holds for all $x$, the second for $x$ that are close to $0$, and they define inverse functions where they are defined.
Similarly, we can define a matrix $\log$ and matrix exponential by means of the exact same power series. $e^A$ will converge for all $A$, and $\ln(I+A)$ will converge for small matrices (take any linear norm on matrices such that $||AB||\leq ||A|| ||B||$, and the condition $||A||<1$ will work).
Unfortunately, these do not obey all the properties that you want. For example, $e^{A+B}=e^A e^B$ only when $A$ and $B$ commute with each other. When they don't commute, the Campbell-Baker-Hausdorff formula says what $\log(e^A e^B)$ equals. Because of this, we do not in general have that $\log AB=\log A + \log B$, even when everything is defined.
Even ignoring this problem, we would still need to define the $\log$ of a vector. I honestly don't know where one would begin, other than to take $\log$ of the individual entries, which wouldn't have any immediately useful properties as far as matrix actions are concerned.
If the problem is that Matlab has rounding errors, then you can exploit the fact that matrix multiplication is a linear operator and just multiply $p$ by some large constant $c$, do the calculation, and then divide by $c$ again. Additionally, if you have problems with $D$ or $K$ being too small/large you can do the same to them.